in reply to Re: regexp match repetition breaks in Perl
in thread regexp match repetition breaks in Perl

Thanks to ikegami et al. for setting me on the path of righteousness!


Re pos($text), I'm doing multiple passes through the document, picking out different things on each pass. So, I need to reset the pos before each pass. 3-digit APC codes are just one of the passes.

I am/was extracting "APC" to help debug the perl/regex. In the final version, I just will extract the code/number.

Thanks, again!
  • Comment on Re^2: regexp match repetition breaks in Perl

Replies are listed 'Best First'.
Re^3: regexp match repetition breaks in Perl
by ikegami (Patriarch) on Jul 12, 2007 at 01:02 UTC

    So, I need to reset the pos before each pass. 3-digit APC codes are just one of the passes.

    Not quite.

    $_ = 'a1!b2.c3?'; print $1 while /([abc])/g; # abc print $1 while /([123])/g; # 123 print $1 while /([!.?])/g; # !.? print "\n";

    Note the lack of the c modifier. That does exactly the opposite of what you want. It's purpose is to prevent pos from getting reset.