in reply to Re: Regex to dereference in thread Regex to dereference
The thing is that if there is only one '\' character, then it should be doubled, but if there is two then not. Basicly if there is even amount then no change, and odd, then change the last. So direct test on last char doesn't really work.
But thanks for the term help. As all my perl (and most of my coding as well) is self-taught :).
Re^3: Regex to dereference
by gaal (Parson) on Jan 19, 2007 at 07:43 UTC
|
Ah, then you need what's called a zero-width negative look-behind.
$str =~ s/(?<!\\)\\$/\\\\/; # match a backslash at the EOL
# that isn't preceded by a backslash
See perlre for more stuff like this. | [reply] [Watch: Dir/Any] [d/l] |
|