regex - How to capture whatever is between an integer and its successor -
how can capture whatever content between integer , successor? example, suppose capture b3c
, between 1
, 2
in a1b3c2d
. code below gives b3c2d
.
'a1b3c2d' =~ / (\d+) (.+) (?{ $1 + 1 }) /x; print $2, "\n";
you need two question marks in construct. 1 puts value of code $^r
, returns match
'a1b3c2d' =~ / (\d+) (.+) (??{ $1 + 1 }) /x; print $2, "\n";
output
b3c
Comments
Post a Comment