home | changes | index | login

Regular Expressions

WareLogging, sort of. Regular expressions are wonderful (and wonderfully ugly) little creatures used to describe patterns in text. Useful in good TextEditors, or in a language like PerlLanguage. This page is a repository of useful regex stuff.

= resources =

= WareLogging =

= thoughts & recipes =

An EvolvingRegularExpression

Use egrep for complex expressions. Otherwise you will have to escape ?, +, {, |, (, and ) in order to get them to behave as special characters. If you're used to writing in Perl or similar, keep in mind that vi / VimEditor pattern matching will treat at least some of these characters as literals unless you escape them.

(?<! ''regex'') ''other stuff'' is a zero-width negative lookbehind assertion. Matches, in other words, if ''regex'' does not precede the ''other stuff''.

egrep -ri "^[a-z., ]+$" ./*.dir Shows lines which are just alphanumeric plus period, comma, and space characters in all files with the extension .dir.

tail -f /var/log/p1k3.access_log | egrep -vi "(googlebot|slurp)" following log file, wanted to avoid bot traffic noise may well eat CPU.

pick a name (required to comment or edit a page)
last edited December 16, 2005