I've had cause to run some code from the console that usually only gets run on a webserver. In its usual environment, it doesn't give me warnings. But, from the console, I get a warning...
$result =~ s/(Mr(s)?) a/\1 A/s; \1 better written as $1 at...
I have always been under the impression (or perhaps illusion) that \1 should be used within the regular expression and $1 outside of it. Like this:
if ($test =~ /some_test/) { $foo = $1; }
Has something changed in the preferred way to capture in a regular expression, or have I been doing it wrong all the time?
In reply to Capture Groups by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |