What is Regex?
These are referred to as regex visualizers, they aid in crafting regex by giving visual aids. Some great software/web apps to start learning are seen below:
- RegExRX ~ http://bit.ly/RegExRX ~ Mac OSX (App store).
- Regex101 ~ http://regex101.com ~ Great online utility.
This tutorial series will cover the regex terminology below.
An atom is any unit that can match.
Matches exactly as presented ‘literally’.
Tries to match an individual character within square brackets [abc]
So far we have only seen literal matches and individual character matches. Regex has the ability to multiply atoms.
Matches start ^ or end $ of string.
\b is a zero width assertion, meaning it doesn’t appear in resulting match but affects the outcome. the \b tries to match instances where a ‘word’ character transitions to a non word (for example white space ).
Tries to match left of | if fails tries the next alternative.
Like a quantifier but it matches a particular amount of times.
Character classes have some shortcut equivalents. These are called metacharacters.
Capture Groups vs non capture groups
Capture groups save to memory a segment within parentheses and assign a variable to it. Starting at 1 and incrementing to 9.
Positive and negative look arounds are zero width assertions. This means they affect the outcome of the match but are not included in the results. (Like word boundaries and anchors).
Modifiers change the behavior of the regex pattern. 2 methods to invoke them (inline) or at the end of the pattern (Varies on programming language/application).