At the
SouthEast LinuxFest, on June 11, 2011, I'll be giving a talk on advanced regular expressions. As a regex becomes more complex, it quickly becomes hard to read. This idea inspired the blog name, Write-Only Code. While that term typically carries a derogatory connotation, I'm embracing it here. I hope to show how expressions may be built in a step-wise fashion with abstraction. Even if the end result looks like line noise, the expression may be understood by the process of its construction. Here's an example from a perl script:
s/^((?:"(?:\\.|[^"])+"|'[^']+'|[^#])*).*$/$1/;
In the next post, I'll build this up in steps with explanations along the way.
No comments:
Post a Comment