Hi except that the position of the substring is off by few chars ?? from where do you index it?
Read pos (and Error in my Regular expression pattern ), learn how pos works
$ perl -Mre=debug -E " for( abcd ){ while( m/./g){ say pos; } } " Compiling REx "." Final program: 1: REG_ANY (2) 2: END (0) minlen 1 Matching REx "." against "abcd" 0 <> <abcd> | 1:REG_ANY(2) 1 <a> <bcd> | 2:END(0) Match successful! 1 Matching REx "." against "bcd" 1 <a> <bcd> | 1:REG_ANY(2) 2 <ab> <cd> | 2:END(0) Match successful! 2 Matching REx "." against "cd" 2 <ab> <cd> | 1:REG_ANY(2) 3 <abc> <d> | 2:END(0) Match successful! 3 Matching REx "." against "d" 3 <abc> <d> | 1:REG_ANY(2) 4 <abcd> <> | 2:END(0) Match successful! 4 Freeing REx: "."
In reply to Re^5: Extract a pattern from a string
by Anonymous Monk
in thread Extract a pattern from a string
by avim1968
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |