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.
As mentioned earlier, you can not parse any recursive structures using regular expressions, because they miss some essential features, like a stack, recursion, or similar.
But in this blog post I also told, that PCRE implements a superset of regular expressions, so that you are able to "parse" more languages, then just regular ones. If someone could send me some proof, which language types can be matched using regular expresions, I would be happy - maybe just implement a turing machine with PCRE regular axpressions?
Some days ago somebody joined a german IRC channel where we try to help others using PHP, where I hang around for some years now, and had some problems with his regular expressions he tried to use to "parse" BBCode he wants to use in his custom application. I answered something like:
It is impossible to parse a language like BBCode with regular expressions because you only may parse regular languages using regular expressions.
The usual reaction: No reaction. No belive. Some days later nearly the same question again, from the same guy, same answer by me, same result. No, not really the same result, I decided to try to summarize the reasons for this in a small blog post.
Regular Expressions are a popular way of performing complex string matching on variables. To anyone who is relatively new to them though, it can be daunting. This guide shows how to use them, with examples for using them in validation techniques.
Was asked recently if I knew of any good regular expressions tutorials (preferably in PHP). The question came from someone certainly smart enough to "get" regular expressions but they’d been unable to find accessible help.
So continuing the fun, Harry Fuecks shows how to deal with RegExp!
Following on from the last part, this one is more of an intermission—a round up of regex syntax seen so far and a couple of links following feedback.
In Linux and Unix, the syntax that is commonly used by many applications for specifying text patterns is known as regular expressions or in short form - regex.
One important use of Regular Expressions (Regex) is to verify fields submitted via a form. In this article, we attempt to write an expression that is able to verify the user's first name, middle name, last name or just names in general.
Regular Expressions (regex for short) appear to a lot of people as the 'black art' of coding. Most languages, be it PHP, Java, C, .NET, VB etc have a way of using regular expressions - and they can certainly make your job easier. So lets start on our journey into regular expressions. I am by no means an expert, but hopefully I'll be able to clear the fog that surrounds regular expressions!








