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