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:

if (/^([+-]?) ((\d+)\.I(\d*)\. (\d+))(?:e([+-]?\d+))?$/) { # floating-point number print 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

1 Expert Approved Answer
Step: 1 Unlock

Capturing subexpressions takes time In an inner loop the cost of unneces... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!