It's kind of pointless for me to be quoting Scott Hanselman -- if you like the following, you probably saw it weeks ago -- but I laughed when I read it, so here goes. This is buried in a tech post about stripping empty XML elements:
The early versions of the Rectifier used an uber-regular expression to strip out these tags from the source string. This system returns a full XML Document string, not an XmlReader or IXPathNavigable.
I heard a cool quote yesterday at the Portland NerdDinner while we were planning the CodeCamp.
"So you've got a problem, and you've decided to solve it with Regular Expressions. Now you've got two problems."
Since the size of the documents we passed through this system were between 10k and 100k the performance of the RegEx, especially when it's compiled and cached was fine. Didn't give it a thought for years. It worked and it worked well. It looked like this:
private static Regex regex = new Regex(@"\<[\w-_.: ]*\>\<\!\[CDATA\[\]\]\>\[\w-_.: ]*\>|\<[\w-_.: ]*\>\[\w-_.: ]*\>|<[\w-_.: ]*/\>|\<[\w-_.: ]*[/]+\>|\<[\w-_.: ]*[\s]xmlns[:\w]*=""[\w-/_.: ]*""\>\[\w-_.: ]*\>|<[\w-_.: ]*[\s]xmlns[:\w]*=""[\w-/_.: ]*""[\s]*/\>|\<[\w-_.: ]*[\s]xmlns[:\w]*=""[\w-/_.: ]*""\>\<\!\[CDATA\[\]\]\>\[\w-_.: ]*\>",RegexOptions.Compiled);
Stuff like this has what I call a "High Bus Factor." That means if the developer who wrote it is hit by a bus, you're screwed. It's nice to create a solution that anyone can sit down and start working on and this isn't one of them.