Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: regex verses join/split

by bwana147 (Pilgrim)
on Jul 27, 2001 at 13:04 UTC ( [id://100252]=note: print w/replies, xml ) Need Help??


in reply to Re: regex verses join/split
in thread regex verses join/split

Interesting, but the OP wanted to remove leading/trailing spaces, and collapse any sequence of whitespaces into one single space. You propose to remove any whitespace anywhere, which is not what was asked for.

Still, it's true that tr/\n\r\f\t / /s would be more efficient than s/\s+/ /g. So, taking your remarks into account, I would say:

s/^\s+//; 1 while s/\s$//; tr/\n\r\f\t / /s;

--bwana147

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found