Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I remove whitespace at the beginning or end of my string?

by Maestro_007 (Hermit)
on Jun 20, 2001 at 20:23 UTC ( #90067=note: print w/replies, xml ) Need Help??


in reply to How do I remove whitespace at the beginning or end of my string?

Try this, it's a little different, though it only works on leading whitespace:
s/\G //g
<paraphrase> It uses the \G anchor with the /g flag to start where the previous match left off, replacing spaces with nothing as it goes along. </paraphrase>

It's from p. 245 of Effective Perl Programming by Joseph N. Hall and Randal Schwartz (merlyn). Randal, if there's a problem with me quoting this stuff, just let me know.

  • Comment on Re: How do I remove whitespace at the beginning or end of my string?
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2023-02-05 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?