Regular Expressions save the day


Regular Expressions (Regex) is a very powerful technology which allows you to process strings using patterns. It gives you the possibility of processing text in a relatively easy and manageable way. Depending on what you need to do, creating a single Regular Expression might save you some pretty complex programming.

Because of its power the Regular Expressions have been implemented in probably every programming language used nowadays (including for the brevity PHP and JavaScript as well). Looking further at Regex two more things become clear.

Regular Expressions are complex

The technology has been out there for decades and it still surprises me how only the few use it fluently. Many beginners are afraid that Regex is too complex for them. Many find it difficult to read, to understand and especially to create one. As soon as you give it a chance however, you’ll find out that you don’t need to be science-analyst to understand it and by learning only the basics of Regex you can solve up to 90% of your Regex related problems. Site like Regular-Expressions.info will definitely help you. On RegExLib.com you will find lots of examples. And if you are a .NET developer you will definitely appreciate The Regulator by Roy Osherove which helps you building and testing regular expressions.

Regular Expressions and programming languages

Another thing becomes obvious after you have worked with Regular Expressions for a bit. As I’ve mentioned earlier, Regex is pretty powerful and has been therefore implemented in many programming languages. The problem is that various details has been implemented differently in various languages. If you’re lucky you will never experience it. If you are less lucky, you might need to learn two dialects: one for your server-side development language and one for the client-side. The odds that you’re programming in more languages are little, but if so, things may get complicated for you.

Regular Expressions save the day

Regular Expressions are way more useful than you think. As soon as you learn them and start using them, you fill discover that your code became easier to read, maintain and there are less complex functions responsible for processing text strings, like retrieving the name of a List/Document Library out of a SharePoint URL. This is definitely one of the personal investments worth doing.

Others found also helpful: