Generating regexes and Gmail filters
- — 16 March, 2009 08:39
Before I launch into my main thrust (a word that must be pronounced with a rolling "r") I have to direct you to a work of near genius, txt2re, an online regular expression code generator.
If you aren't au fait with regular expressions (also called regexes or regexps), they are formal descriptions of searches to be conducted on sequences of characters (or "strings") by a regular expression processor, that is, a program designed to process "regexes" (see the Wikipedia entry on regular expressions).
To use txt2re you give the service an example string and it shows you the substrings it recognizes and lets you select which ones you want to include in the output.
192.168.10.11 - bob [16/Mar/2009:13:14:15 -0800] "GET /gibbs.gif HTTP/1.0" 200 5648
Txt2re failed to offer to treat the last digits in the string that show the data length as an integer -- it only offered them as four individual digits (see here), which would be useless if the data length was five digits long.