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

Re: Can this be a 1 line or simpler regex?

by diotalevi (Canon)
on Apr 05, 2003 at 07:35 UTC ( #248270=note: print w/replies, xml ) Need Help??


in reply to Can this be a 1 line or simpler regex?

(fixed the code)

I suppose a single regex could be devised for this but it'd be suboptimal compared to what you already have. A short loop would also do this and again, I prefer your original.

$text =~ s/\\$r/\\\\$r/g for qw/t n r f/;
for(qw't n r f') { my $r = "\\$_"; $text =~ s/$r/$r/g; }

Replies are listed 'Best First'.
Re^2: Can this be a 1 line or simpler regex? (that doesn't work)
by Aristotle (Chancellor) on Apr 06, 2003 at 02:17 UTC
    How's that supposed to work? As is it's a no-op.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2023-03-26 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?