Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Aristotle (Chancellor)
on Apr 06, 2003 at 00:02 UTC ( #248357=note: print w/replies, xml ) Need Help??


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

$_ = "one\ttwo\nthree four five\r"; s/(\t)|(\n)|(\r)|(\f)/ ($1 && '\t' || '') . ($2 && '\n' || '') . ($3 && '\r' || '') . ($4 && '\f' || '') /ge;
Update:
$_ = "one\ttwo\nthree four five\r"; s/(\t)|(\n)|(\r)|(\f)/ $1 ? '\t' : $2 ? '\n' : $3 ? '\r' : $4 ? '\f' : '' /ge;

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://248357]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2023-03-24 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?