Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: contextual substitution with s///?

by choroba (Bishop)
on Feb 01, 2013 at 16:13 UTC ( #1016575=note: print w/replies, xml ) Need Help??


in reply to contextual substitution with s///?

Capture what should remain, not what should change:
$s = "test string x x\nFeb 1 09:12:33 ("; $s =~ s/^(\w{3}) /$1 /m;
Also note that if you are matching multiline string, the /m modifier is needed to match after a newline.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016575]
help
Chatterbox?
and snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-11-19 19:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (282 votes). Check out past polls.

    Notices?