Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-03-20 20:06 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (259 votes). Check out past polls.