in reply to Re: One or more of a pattern...
in thread One or more of a pattern...

Don't use ^ and $ when you mean \A and \z!

-sam

Replies are listed 'Best First'.
Re: Re: Re: One or more of a pattern...
by dsheroh (Monsignor) on May 11, 2002 at 13:37 UTC
    In this case, where the string the pattern is being run against was obtained from a while (<FILE>) (and should, therefore, be a single line), how do they differ and why do you prefer \A/\z?
      The post was in response to a question about matching against a string. I assumed the poster would just take the regex and stick it into his code unaltered. In that case ^ and $ are clearly wrong since the could allow a bad string like "foo(10):bar(20)\n!!!!!!!!!!" to match. By contrast \A can only mean the start of the string and \z can only mean the end of the string. They are unambiguous and do not depend on options to determine their match.

      Does that answer your question?

      -sam