Regular Expressions "Exclude"

Results 1 to 2 of 2

Thread: Regular Expressions "Exclude"

  1. #1
    Join Date
    Dec 1969

    Default Regular Expressions "Exclude"

    It seems Regular Expressions build collections that are inclusive of what's declared in the pattern. How do you build a collection that is exclusive of the pattern?

  2. #2
    Jeffrey Friedl Guest

    Default RE: Regular Expressions

    I don&#039;t know a lot about Microsoft products, but if you&#039;re<BR>talking about the regexes in VBScript, see<BR><BR><BR><BR>and note the (?!...) notation. It&#039;s a "negative lookahead".<BR>It "matches" when, at the point during the match that you<BR>come across it, the regex inside (represented by "..." above)<BR>can *not* match.<BR><BR>As a simple example, here&#039;s something that matches an even<BR>digit:<BR><BR> (?!13579)d<BR><BR>Of course, this matches the same as<BR> [02468]<BR>so it&#039;s a silly example, but it&#039;s a good example for showing<BR>negative lookahead.<BR><BR>Here&#039;s another (silly) example:<BR> Microsoft Windows(?! sucks)<BR><BR>It will match "Microsoft Windows" only when *not* followed<BR>by " sucks". You might use this for searching for complimentary<BR>references in Linux archives, or something :-)<BR><BR>The opposite is posative lookahead, (?=...).<BR><BR>Another kind of opposite, negative lookbehind, is not available<BR>(at least according to the web page I referenced above -- perhaps<BR>they&#039;ll add it sometime).<BR><BR> Jeffrey

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts