Sep 13, 2012

Regex Pre Match, Post Match, Exact Match

$& = Exact Match
$` = Before Match
$' = After the Match


    $var="i_love_regular_expressions";
   
    if($var =~ /regular/)
    {
        print "Exact Match:",$&,"\n";
        print "Beofre the Match:",$`,"\n";
        print "After the Match",$',"\n";
    }

output:
Exact Match :regular
Before Match :i_love_
After Match :_expressions

No comments:

Post a Comment