Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: rearranging a string.new

by davidrw (Prior)
on Nov 21, 2005 at 19:25 UTC ( [id://510533]=note: print w/replies, xml ) Need Help??


in reply to rearranging a string.new

Can also use a regex or substitution...
my $string = '20050516'; my $newstring; $newstring = $2 . $1 if $string =~ /(\d{4})(\d{4})/; warn $newstring; (my $newstring = $string) =~ s/(\d{4})(\d{4})/$2$1/; warn $newstring;
Could also use a more robust regex if desired (trivial example is /(200[012345])(\d{4})/) and depending on context.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2025-07-08 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.