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

Re: Swapping two parts of a string

by FunkyMonk (Bishop)
on Jul 22, 2007 at 20:45 UTC ( [id://628145]=note: print w/replies, xml ) Need Help??


in reply to Swapping two parts of a string

my $input = "(55.950254, -3.187606)"; ( my $output = $input ) =~ s{([-\d.]+), # capture the first number to + $1 \s+ # at least one space ([-\d.]+) # capture the second to $2 } {$2 $1}x; # reverse $1 & $2 print $output;

See perlre and perlretut for help with regular expressions, and Regexp Quote-Like Operators in perlop for s///.

update: added references to documentation

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2026-04-13 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.