Some Perl Special Variables
Some Regular Expression Special Variables
23 of 28 : [
PREV
] [
NEXT
]
$` ($PREMATCH)
The string preceding whatever was matched by the last successful pattern match.
$& ($MATCH)
The string matched by the last successful pattern match.
$' ($POSTMATCH)
The string following whatever was matched by the last successful pattern match.
$_ = "AlphaBetaGamma";
/Beta/;
print "Prematch = $`\n"; # Alpha
print "Match = $&\n"; # Beta
print "Postmatch = $'\n"; # Gamma
© 2004 Barbie
barbie@missbarbell.co.uk
Home
http://birmingham.pm.org/