in reply to Re: Matching Character Patterns With Backreferences
in thread Matching Character Patterns With Backreferences

I'm having trouble getting this to work with the $1 form - it's simply not matching anything the moment I make that change.

The \s is simply because each line of the dictionary file contains a word followed by whitespace. Checking for the space stops me from printing out "TESTING" when I only want "TEST" :-)

  • Comment on Re^2: Matching Character Patterns With Backreferences

Replies are listed 'Best First'.
Re^3: Matching Character Patterns With Backreferences
by BUU (Prior) on Dec 06, 2004 at 00:42 UTC
    You should be using \1 and friends in the left hand side of the s/// operator.
      Are you sure? I believe it's the other way around; you should use $1 and friends on the right hand side of the s/// operator. That's what the warning in perlre is about, anyway.
        What? Yes I'm sure. Of course you should use $1 on the right hand side of the s/// operator, as thats merely a double quoted string. The warning in perlre is regards to using \1 on the right hand side, which only works because of a hack.