Question: Perl provides an alternative (?:. . . ) form of parentheses that supports grouping in regular expressions without performing capture. Using this syntax, Example 14.57
Perl provides an alternative (?:. . . ) form of parentheses that supports grouping in regular expressions without performing capture. Using this syntax, Example 14.57 could have been written as follows:
What purpose does this extra notation serve? Why might the code here be preferable to that of Example 14.57?
if (/^([+-]?) ((\d+)\.I(\d*)\. (\d+))(?:e([+-]?\d+))?$/) { # floating-point number print "sign: print "integer: ", $3, $4, " "; print "fraction: print "mantissa: " print "exponent: ", $6, " "; ", $1, " "; $5, " "; $2, " "; # not $7 %3D
Step by Step Solution
3.44 Rating (154 Votes )
There are 3 Steps involved in it
Capturing subexpressions takes time In an inner loop the cost of unneces... View full answer
Get step-by-step solutions from verified subject matter experts
