in reply to Something is wrong with this pattern

What does $operator contain?

As a general comment: .+? at the start or end of a regex will never match anything - don't do that. It's also good practise to use a character set in place of . when using * to avoid capturing more than you intend.

True laziness is hard work
  • Comment on Re: Something is wrong with this pattern

Replies are listed 'Best First'.
Re^2: Something is wrong with this pattern
by JavaFan (Canon) on Dec 24, 2010 at 10:34 UTC
    As a general comment: .+? at the start or end of a regex will never match anything
    False:
    $ perl -wE '"abcdef" =~ /(.+?)f/ and say $1' abcde
    Remember, "left-most match" trumps "shortest match".

      Sigh, yes you are quite right and I didn't remember. Can we blame it on too much pre-Christmas cheer? Merry Christmas. ;)

      True laziness is hard work