Decrypting Regular Expressions
The way regular expressions are constructed follows some basic rules that are the same on every platform and implementation; however, there are some implementation-specific rules that might vary depending on the platform and implementation the regular expression was constructed for.
Let's revisit our initial email pattern matching /.+\@.+\..+/
expression. We can see that it starts with a slash mark like this, /
and ends with a /
. These are the opening and closing markers for the expression; anything within these characters belongs to the actual expression.
Regular expressions are constructed from a few basic components; they are character classes, anchors, groups, and special escape characters. Then, we have the quantifiers that control how many of the preceding characters should be matched. Last but not least, we have the expression flags, which control certain behaviors for the whole expression. Let's look at them in more detail in the...