What are Regular Expressions?
Regular expressions are special strings that describe search patterns inside a text. They are composed of specific rules for matching a set of characters that can not always be easily found in a normal search.
They started in the 1940s as a way to describe regular languages, but they only began to show up in the programming world during the 1970s. Currently, regular expressions are very popular among programmers and they are extremely helpful in a lot of situations.
What Regex can be used for?
Regular expressions has many uses. Here there are some examples:
- Find and replace huge amount of data that follow the same pattern.
- Define rules for allowing or denying access of urls in a application.
- Gather files that has the same extension and have similar nomenclature.
- Capture occurrences of and specific pattern and create groups with it.
- And so much more...
Regular expression engines (flavors)
Each programming language or search tool that supports regex has an engine behind it. Engines, also known as flavors, are the syntax and additional properties and features supported by the particular regular expression tool. Different implementations of regex engines support different types of syntaxes.
For example, Perl compatible engines support \d
for matching digits. Javascript doesn't allow lookbehinds. Anyway, it all varies between each language. In this training, we are going to focus on the most common features, all supported by the PCRE flavor.