Common Regular Expression Mistakes
- Forgetting to enclose the regular expression in ' '.
- Including spaces in the regular expressions (other than
spaces you want).
- Not escaping special characters you want treated literally:
e.g. '()' instead of '\(\)'.
- Forgetting the ^ and $ when you want an
entire line to match a regular expression rather than some
substring of the line.
- Forgetting that something * includes the null string. For
example, the regular expression
(aaa|bbb)*
matches every line!
Prof Christopher W Brown
Last modified: Tue Sep 12 15:57:02 EDT 2000