[html-formfu] Filter::TrimEdges - Just Curious

Dermot paikkos at googlemail.com
Wed Feb 11 09:31:56 GMT 2009


2009/2/11 Carl Franks <fireartist at gmail.com>:
> 2009/2/11 Dermot <paikkos at googlemail.com>:
>> Hi,
>>
>> Sorry if I am being a bore but I was curious, TrimEdges uses "$val =~
>> s/\s+\z//;" to remove white-space from the end of a string. I can't
>> find a character class for \z. How does \z differ from $?
>
> Don't be afraid to ask! :)
>
> \z isn't a character class: it's an anchor, and makes sure we're
> really at the end of the string.
> $ can match before a newline at the end of the string - which isn't
> usually what we want.
>
> According to `perldoc perlre`...
> $       Match the end of the line (or before newline at the end)
> \z      Match only at end of string

Thanx Carl.

I was scanning perlre but didn't find it. Got it now

The \A  and \Z  are just like "^" and "$", except that they won't
match multiple times when the /m modifier is used, while "^" and "$"
will match at every internal line boundary. To match the actual end of
the string and not ignore an optional trailing newline, use \z .
Dp.



More information about the HTML-FormFu mailing list