pat_mc has asked for the wisdom of the Perl Monks concerning the following question:
Hi there, esteemed Monks!
I am having trouble with the upper and lower case backslash escapes in regular expressions and would very much appreciate your help with these.
So far, I thought \l matches lowercase characters, similar to [a-z] would for English text. This is obviously wrong:
This seems to work. An analogous result is obtained for \u
My question is: Can I used those escape characters in a matching pattern as well - and if so, what is their meaning in that context?
Really appreciate your wisdom.
Cheers -
Pat
I am having trouble with the upper and lower case backslash escapes in regular expressions and would very much appreciate your help with these.
So far, I thought \l matches lowercase characters, similar to [a-z] would for English text. This is obviously wrong:
I then thought it acts like an operator to modify substitution strings:$ perl -e '( $a = "hello" ) =~ s/^\l//; print $a' hello
$ perl -e '( $a = "Hello" ) =~ s/(.+)/\l$1/; print $a' hello
This seems to work. An analogous result is obtained for \u
My question is: Can I used those escape characters in a matching pattern as well - and if so, what is their meaning in that context?
Really appreciate your wisdom.
Cheers -
Pat
Back to
Seekers of Perl Wisdom