Rules Applied
Explanation of RegEx
The rules list is a list of Regular Expressions (RegEx). A Regular Expression acts as a smarter form of "Find and Replace". Unlike the basic "Find and Replace", RegEx is capable of finding and replacing patterns.
For example, the RegEx Request (?:to Admit|for Admissions) will find both "Request to Admit" and "Request for Admissions".
The | acts as an "or", telling the RegEx to match whether the text is "to Admit" or "for Admissions".
The (?:) limits the scope of the | to only the text inside the parentheses.
Another useful RegEx pattern is square brackets [].
Square brackets tells the RegEx to match any character inside the brackets.
Using hyphens, you can specify a range of characters.
For example, [A-Z] will match any capital letter.
[a-zA-Z0-9] will match any letter or number.
[a-zA-Z0-9 ] will match any capital letter, number, or space.
RegEx can also specify how many times a character or group of characters should be matched.
For example, [a-zA-Z0-9 ]{1,3} will match any capital letter, number, or space, 1 to 3 times.
This means that all of the following options can be matched with this singular expression:
(note that this list is not exhaustive)
- a
- ab
- abc
- zzz
- bAB
- 999
- 543
- 44
- 8s
- o4F
- i 8
- 5
- G
- And any other combination of 1-3 case-insensitive letters, numbers, or spaces...
Finally, for this explanation, RegEx can do something called "capturing".
Capturing is when you use parentheses () to tell the RegEx to remember a certain part of the text.
You can then use that captured text in the replacement text.
For example, ([0-9]{3}) will capture any set of 3 consecutive numbers.
You can then use $1 in the replacement text to insert the captured text.
For example, if you wanted to add a hyphen between the first 3 numbers and the last 4 numbers of a phone number, you could use the RegEx ([0-9]{3})([0-9]{4}) and the replacement text $1-$2.
This would turn the phone number 1234567890 into 123-4567.
Fore more information, see this RegEx resource. It is very useful for testing/understanding RegEx.