in reply to Re^2: Extract a pattern from a string
in thread Extract a pattern from a string
The reason is that the 'index' operator re-scans the string, while 'pos' uses an existing value, and the 'length' computation is significantly faster than scanning.perl -E 'my $s="ME170-5/2/8-ME172-2/2/6-ME4028"; while ($s=~m|(\d{1,2 +}/\d{1,2}/\d{1,2})|g){++$x;say "$x Found $1:" . " POS=" . (pos($s)-l +ength($1)+1)}'
I hope life isn't a big joke, because I don't get it.
-SNL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Extract a pattern from a string
by avim1968 (Acolyte) on Jun 11, 2012 at 05:35 UTC | |
by NetWallah (Canon) on Jun 11, 2012 at 13:54 UTC | |
by avim1968 (Acolyte) on Jun 14, 2012 at 05:15 UTC |