1 |
The variables \1, \2, \3 etc. correspond to parentheses inside the regex. Outside the regular expression use the PERL variables $1, $2, $3 etc.
|
2 |
In string matching, we identify three parts:
-
$` is variable holding substring BEFORE matched part
-
$& is variable holding substring matched by regular expression
-
$' is variable holding substring AFTER matched part
|
3 |
So original string is the concatenation $` . $& . $'
|
4 |
Note, however, any script that uses these variables suffers a significant performance hit!
|