in reply to Re: Extract a pattern from a string
in thread Extract a pattern from a string

Hi
thank you very much, i understand now were i was wrong.
i took your code as a base and modified it a bit and it works great.
except that the position is off by few chars ??
from where do you index it?

I do have a question, why does the matchs come out
in $1=4 $2=2 $3=5 and not as a single substring "4/2/5"
is there a way to get it like this?
thank you
Avi

Replies are listed 'Best First'.
Re^3: Extract a pattern from a string
by Anonymous Monk on Jun 10, 2012 at 09:00 UTC

      Hi
      thank you for your answer, i have made the needed changes
      and now i get the full pattern.
      Avi

      Hi except that the position of the substring is off by few chars ??
      from where do you index it?
      Avi

        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: "."