Beyond black magic: Regex gotcha
Personally I love using regular expressions. It simply the best way to parse/split/replace/validate pieces of text. Many people look at regular expressions as black magic. They might be able to create a regex, but don’t understand the flow. When you are creating more advanced expressions, it is important to understand the inner workings for many reasons, including performance.
Let’s have a look at the following regular expression: ^(\d+)(\d+)(\d+)$. It matches one or more digits and does that three times. It is an illogical expression, but bear with me.
Let’s match the string “12345678901234567890″. When we look at the inner workings of the regex engine we can see what is happening:
Continue Reading »
25 Nov 2007 Arnold Daniels 0 comments




