Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Regex to dereference

by Hena (Friar)
on Jan 19, 2007 at 06:40 UTC ( [id://595410]=note: print w/replies, xml ) Need Help??


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 :).

Replies are listed 'Best First'.
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://595410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found