Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Removing extra spaces

by johngg (Abbot)
on Jul 31, 2012 at 09:16 UTC ( #984588=note: print w/ replies, xml ) Need Help??


in reply to Removing extra spaces

You could use a negative look-ahead to replace any space that is not followed by a space with nothing. This will break down if there are more than two spaces though.

knoppix@Microknoppix:~$ perl -E ' > $dateStr = q{ 2 0 1 2 - 7 - 2 7 9 : 3 7 : 3 1 }; > $dateStr =~ s{\s(?!\s)}{}g; > say $dateStr;' 2012-7-27 9:37:31 knoppix@Microknoppix:~$

Cheers,

JohnGG


Comment on Re: Removing extra spaces
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-31 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls