A regular expression is a string that describes or matches a set of strings, according to certain syntax rules. Regular expressions are used by many text editors and utilities to search and manipulate bodies of text based on certain patterns.
We will be using regular expressions to match patterns in the client URL and redirect them accordingly. Regular expressions are an invaluable skill to learn if as both a programmer and a systems administrator. To redirect URLs according to the examples in this document, you will only have to understand the basics of using regexes. This is a list of the characters and operators you will use in the regexes described in this document:
- . Period - matches anything.
- * Asterick – matches zero or more of the preceding character
- + Plus sign – matches one or more of the preceding character
- ( ) Parenthesis - enclosing a value in parenthesis will store what was matched in a variable to be used later. This is also referred to as a back-reference.
- (value1|value2) - Enclosing two or more values in parenthesis and separating them with a pipe character is the equivalent of saying: “matching value1 OR value2.”