grouping - Maximum number of captured groups in perl regex -
given regex in perl, how find maximum number of captured groups in regex? know can use $1, $2 etc reference first, second etc captured groups. how find maximum number of such groups? captured groups, mean string matched regex in paranthesis. ex: if regex (a+)(b+)c+ string "abc" matches regex. , first captured group $1, second $2.
amon
hinted @ answer question when mentioned %+
hash. need @+
array:
@+
this array holds offsets of ends of last successful submatches in active dynamic scope. $+[0] offset string of end of entire match. same value pos function returns when called on variable matched against. nth element of array holds offset of nth submatch, $+1 offset past $1 ends, $+[2] offset past $2 ends, , on. you can use $#+ determine how many subgroups in last successful match. see examples given @- variable. [enphasis added]
$re = "(.)" x 500; $str = "a" x 500; $str =~ /$re/; print "num captures $#+"; # outputs "num captures 500"
Comments
Post a Comment