Tuesday, September 18, 2007

Regex - Replacement Count

When you bind a variable to a substitution, the expression as a whole will return the number of substitutions made, e.g. ,
$replacements =$myvar =~s/foo/bar/g;
$replacements will give you the total count of replacements.

No comments: