in reply to Mind boggling regex

Character classes are formed at regex compile-time, and \1 isn't a backreference until regex run-time, so your character class is saying "all characters except the character with octal code 001". Try something like:
$word =~ /(e)(?!\1)(.)e/s;
which reads "match an e, then, making sure we CAN'T match an e, match ANY character, then match an e." The /s is there so that . matches newline.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Mind boggling regex
by Anonymous Monk on Oct 26, 2001 at 21:40 UTC
    $word =~ /(e)(?!\1)(.)e/s;
    I just tried that regex, and $1, $2, and $3 are all undefined.

    Does the look-ahead somehow make all the saved regex matches disappear or something?

    Magius_AR

      Well, the regex FAILS for the string "eee". Try "eye" instead. And this regex only defines $1 and $2.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;