1. Home
  2. Computing & Technology
  3. Python

Python Regular Expressions (regex): Regex Negation ('(?!)')

By Al Lukaszewski, About.com

Definition:

Where '?=' expresses the necessary appearance of two expressions, '?!' expresses the necessary appearance of the one only if the second is not present. The syntax of this operator is similar to its positive counterpart:

expression A (?!expression B)
When expression A is found, Python queries for expression B to follow it. If expression B is not found, the regex is said to match, and the hit is returned.


Back to the main index of this glossary

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python
  4. Regular Expressions
  5. Python RegEx Glossary
  6. Parenthetical Compounds
  7. Python Regular Expressions (regex): Regex Negation ('(?!)')

©2008 About.com, a part of The New York Times Company.

All rights reserved.