in reply to Re^2: Stupid question about regex with string followed variable in replacement
in thread Stupid question about regex with string followed variable in replacement
This converts the "1" to "10".my $txt = '1,2'; $txt=~ s/(\d+)\,(\d+)/$1\Q0\E,$2/;
Unfortunately, simply escaping like "\0" does not work for many cases, because many escape sequences have special meaning .. Eg: \0 starts an octal sequence. See "perldoc perlrebackslash"
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Stupid question about regex with string followed variable in replacement
by LanX (Saint) on May 20, 2013 at 00:37 UTC | |
|
Re^4: Stupid question about regex with string followed variable in replacement
by Anonymous Monk on May 19, 2013 at 23:21 UTC |