Tag: regex

Regular expressions for pros

Regular expressions are powerful string-manipulation tools, though chances are you probably don’t even know half of what is possible with them. Before touching some of the PCRE awesomeness, make sure you’re quite familiar with regular expressions already.

Though you probably won’t use any of the below on a daily basis, you should definitely be aware of their existence. The exact syntax might’ve slipped your mind by the time you get to use some of these, but I guess you can always come back to refresh your memory once you need it, right?

If you know all about the stuff in the basics tutorial already, dive in!

Introduction to regular expressions

Regular expressions are under-valued and most developers tend to only know the basics. Having a thorough understanding of how regular expressions work, will be incredibly helpful when you need to parse structured data.

In essence, a regular expression – or regex – is an instruction set to parse “certain data” in a “certain string”. A simple example of such regex is /[0-9]+/: instructions to find numeric occurrences in a string.

Regular expressions are most commonly PCRE-based, an instruction set derived from the regular expression implementation in Perl. I’ll be discussing the PCRE implementation in PHP in particular. While in other programming languages the specific implementation may differ, most modern languages have PCRE ( Perl Compatible Regular Expressions) support and the concepts should and will largely be the same in the language of your choice.