What are Regular Expressions? (Regex, Regexp)
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:
- Atoms =~ An atom is any unit that can match.
- Literal Matches =~ Matches exactly as presented ‘literally’.
- Character Classes =~ Tries to match an individual character within square brackets [abc]
- Quantifiers =~ So far we have only seen literal matches and individual character matches. Regex has the ability to multiply atoms.
- Anchors =~ Matches start ^ or end $ of string.
- Boundaries =~ \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 ).
- Alterations =~ Tries to match left of | if fails tries the next alternative.
- Iteration =~ Like a quantifier but it matches a particular amount of times.
- Metacharacters =~ 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.
- Lookarounds =~ 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 =~ 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).