Regular expressions allow us to craft rudimentary if-then-else statements within the expression itself. These allow us to ensure that if specific match parameters are met, a defined subexpression is matched; if they are not, the regex engine continues to attempt to match the expression using the expression in the "else" section of the expression. This allows us to refine our matches further and opens up the opportunity to craft simple
if statements in programs like
grep, without needing to use a more extensive scripting language.
Get the lesson files here!: