in reply to Re^2: number of numbers in a string
in thread number of numbers in a string
This makes use of the triangular pattern that the number "1234" has 10 "embedded numbers" (1234, 123, 12, 1, 234, 23, 2, 34, 3, 4). No need to put all that hard work in the regex itself. Although, if you wanted to, it'd be:my $n = 0; $n += map .5*(1+length)*length, $s =~ /\d+/g;
our $n; $s =~ /\d+(??{ ++$n })(?!)/;
|
|---|