|We don't bite newbies here... much|
Replacing multiple spaces into one character?by r.joseph (Hermit)
|on Oct 09, 2001 at 07:02 UTC||Need Help??|
r.joseph has asked for the
wisdom of the Perl Monks concerning the following question:
Hey all. Suppose the string: . . .Perlmonks . . .is . .the . . . .coolest .place. Notice how each dot respresents a space (I did that for clarity, so that you could visualize multiple spaces (including leading spaces) - just realize that there can be any number of space between words).
I want to take the above string and turn it into: Perlmonks_is_the_coolest_place
Basically, replacing any number of spaces between words with ONE underscore. I tried:
but that replaces each space with an underscore. Removing the "g" modifier from the regex does (obviously) no good.
I realize that this will probably end up being a very simple solution, but I have been studying all day and my brain is fried, so please help a poor, brain-fried college student out? Thanks all!
r. j o s e p h
"Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov