Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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.

Abigail

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.

    -Chuckularone

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2016-06-30 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (388 votes). Check out past polls.