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

542Re: [NTS] Can a Reg Exp handle 123 AND not a|b|c followed by x?

Expand Messages
  • flo.gehrke
    May 10, 2012
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > I am not understanding something here – The criteria was:
      > three characters that are *NOT* MON|TUE|WED|THU|FRI|SAT|SUN
      >
      > How is this avoiding those strings? I've wanted to do this text
      > that didn't contain a certain string on multiple occasions.
      >

      John,

      The second part of that RegEx...

      \((?!Mon|Tue|Wed|Thu|Fri|Sat|Sun).{3}\)

      matches an opening and a closing literal bracket '(...)' embracing three digits '.{3}' that are NOT 'Mon', 'Tue' etc, as Joy demanded.

      The 3-digit-days are excluded with a Negative Lookahead. Since a Lookahead doesn't consume any character, any different 3-digit-string will match at the same position between the opening and the closing bracket. That's why, for example,..

      'John' is matched with '(?!Mary)John'

      that is: Find 'John' at a position where you don't see 'Mary' when looking ahead.

      Regards,
      Flo
    • Show all 13 messages in this topic