Loading ...
Sorry, an error occurred while loading the content.

20094[PBML] Re: Compact digital range RexEx - And complement?

Expand Messages
  • Allan Dystrup
    Dec 1, 2004
      Hi Jonathan ,

      Yes indeed, i've reached the same conclusion.
      The (?!pattern) can solve the issue in as clean a way
      as it's probably possible with Regex'es. Eg:

      Range RegEx Complement
      ----------- ----------- ----------
      CX365-CX366 CX36(5|6) ^(?!CX36(5|6))
      JA300-JA302 JA30[0-2] ^(?!JA30[0-2])
      JA320-JA394 JA3(([2-8]\d)|(9[0-4])) ^(?!(JA3(([2-8]\d)|(9[0-4]))
      etc.

      Thanks a lot,
      Allan


      --- In perl-beginner@yahoogroups.com, Jonathan Paton <jepaton@g...>
      wrote:
      > Dear Allan,
      >
      > I think you are looking for:
      >
      > "(?!pattern)"
      > A zero-width negative look-ahead assertion. For
      example
      > "/foo(?!bar)/" matches any occurrence of "foo"
      that isn't
      > followed by "bar". Note however that look-ahead
      and look-
      > behind are NOT the same thing. You cannot use
      this for
      > look-behind.
      >
      > ...
      >
      > from perldoc perlre
      >
      > You might need to wrap the regex with ^ and $ assertions.
      >
      > Jonathan Paton
    • Show all 20 messages in this topic