Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Reaplcing double spaces

by ducky (Scribe)
on Sep 23, 2001 at 02:48 UTC ( [id://114109]=note: print w/replies, xml ) Need Help??


in reply to Replacing double spaces (was: Reaplcing double spaces)

Hmmm... tr just does translating. ie, First character in the left hand list gets replaced with the first character in the right hand list, etc. Try replacing tr with s and adding "g" to the end. If you've got a variable number of spaces something like: s/ +/|/g should work.

(see update II) Since it's 2 or more, use this: s/  +/|/gThat's two spaces, then a + to gobble the additional spaces.

HTH

-Ducky

update:Gah! typos galore! =/

update II:Based on the reply, added a mo' bettah, should work kinda answer.

Replies are listed 'Best First'.
Re: Re: Reaplcing double spaces
by DaWolf (Curate) on Sep 24, 2001 at 07:54 UTC
    Ducky, you're my hero :)

    Thanks a lot, everyone.

    Er Galvão Abbott
    a.k.a. Lobo, DaWolf
    Webdeveloper
Re: Re: Reaplcing double spaces
by DaWolf (Curate) on Sep 24, 2001 at 00:05 UTC
    Sorry, guys. I did not made one point very clear:

    I need to replace ONLY two or more spaces. If there is only one space it have to be left the way it is. So, for a new example:

    Apple Pie    Banana Ice    Lemon Juice

    What I need:

    Apple Pie|Banana Ice|Lemon Juice

    Any thoughts?

    Er Galvão Abbott
    a.k.a. Lobo, DaWolf
    Webdeveloper

      Aha! gotcha covered, big guy =) See my reply again for my final answer

      -Ducky

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-20 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found