Regular expressions can contain "extended" syntax (where whitespace is optional, so a regular expression can be split over multiple lines, and can contain regular Perl comments), and can have positive and negative "lookahead." The syntax is a bit ugly, so rather than scare you off here, go look in Programming Perl , or see the perlre (1) manpage. Friedl's book, Mastering Regular Expressions (published by O'Reilly & Associates) explains all of this and much more.