Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Answer: 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=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I remove whitespace at the beginning or end of my string? - Answer contributed by Maestro_007

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 Answer: 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
Chatterbox?
[Corion]: erix: Well, they also seem to have changed the server, or some software, or whatever, and seem to be in the process of changing the DB schema from having the "username" as primary key to something else.
[Corion]: Far too many things being done at once, or maybe only now has it become apparent that nobody knows that piece of software anymore
[marto]: good morning all
[Corion]: I consider having an abstract key as userid in your system good, because the "real" company-wide (or even larger) user id will likely not fit your criteria well
[Corion]: A good morning marto!

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-01-23 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (192 votes). Check out past polls.