Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: A serch and replace question

by Abigail-II (Bishop)
on Oct 31, 2003 at 16:32 UTC ( #303596=note: print w/replies, xml ) Need Help??

in reply to A serch and replace question

That's because | is special to the regexp engine, and using hex escapes isn't going to disable that. Try this:
$data =~ s/\x0d\x0a[|][|]/||/g; # No /s needed.


Replies are listed 'Best First'.
Re: Re: A serch and replace question
by benizi (Hermit) on Oct 31, 2003 at 18:27 UTC

    Not true. Using -Mre=debug (output trimmed a bit)
    /a|b/ yields:

    Compiling REx `a|b' 1: BRANCH(4) 2: EXACT <a>(7) 4: BRANCH(7) 5: EXACT <b>(7) 7: END(0) minlen 1

    but /a\x7cb/ yields:
    Compiling REx `a\x7cb' 1: EXACT <a|b>(3) 3: END(0) anchored `a|b' at 0 (checking anchored isall) minlen 3

    (tested w/ 5.005_03, 5.6.0, and 5.8.0)
Re: Re: A serch and replace question
by ChuckularOne (Parson) on Oct 31, 2003 at 19:23 UTC
    I figured using Hex escapes would get around that issue. I guess I was wrong. Thanks.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2016-10-22 02:46 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.