«

Regular Expression Hell

Regular Expressions are really powerful for searching, filtering, pattern matching and a thousand other things. But they are also super annoying. The syntax is far from readable for anyone who hasn’t been using it for years. Add to that the fact that there are different syntax rules for Perl vs. .Net vs. XSD Patterns vs. who knows what and you have a recipe for annoyance.

Today’s fun exercise was banging my head against the wall trying to find out why my regular expression which worked in my .Net and JavaScript wouldn’t work inside of my schema. The MSDN docs says that the character ‘^’, when used outside of a character set, marks the beginning of a line. So, to match “Gerrard” + one or more characters I used:

^Gerrard.+

Well, in XSD patterns the ‘^’ character is always a negation. I didn’t even know there was a different syntax! Annoying.