in reply to Re: Re: RegEx Problem
in thread RegEx Problem

Nope, the regex is fine as it isn't re-entrant. If there was regex *within* the regex then that would be re-entrant, but as far as perl is concerned you can do as you please in the replace part of a s///.

So this code will break[1]

my $str = "foo bar baz quux"; $str =~ s<([a-z]+) (?{ s| \1|\L$&|; })><\U$1>xg;
But this is fine
$str =~ s<([a-z]+ ?)><local $_ = $1; s/$1/\U$&/g; $_>eg;

HTH

_________
broquaint

[1] in theory, I'll be happy to change it to a proper re-entrant regex if someone will provide me with one

Replies are listed 'Best First'.
Re: Re: Re: Re: RegEx Problem
by samtregar (Abbot) on May 29, 2002 at 15:29 UTC
    D'oh. I stand corrected. Is this documented anywhere that you know of?

    -sam

      I can't find anywhere in the distribution docs or any books I've searched so far that mention the problem of re-entrancy in regexes. I'm fairly sure it's covered in the monastery somewhere and has definitely been covered a few times in p5p.
      HTH

      _________
      broquaint