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

Because that is how the pattern was written, each () corresponds to $n, so the first () is $1 the second is $2 and so on. Read http://perldoc.perl.org/perlintro.html#Parentheses-for-capturing, perlrequick and/or something from Tutorials

Replies are listed 'Best First'.
Re^4: Extract a pattern from a string
by avim1968 (Acolyte) on Jun 10, 2012 at 10:01 UTC

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

Re^4: Extract a pattern from a string
by avim1968 (Acolyte) on Jun 10, 2012 at 09:28 UTC

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