I came across this amazing resource when reading about regular expressions.
It has this gem of a definition for regular expressions (ie Regex):
What is a Regex?
First, a regex is a text string. For instance, foo
is a regex. So is [A-Z]+:\d+
.
Those text strings describe patterns to find text or positions within a body of text. For instance, the regex foo
matches the string foo , the regex [A-Z]+:\d+
matches string fragments like F:1 and GO:30 , and the regex (?<=[a-z])(?=[A-Z])
matches the position in the string CamelCase where we shift from a lower-case letter to an upper-case letter.
Typically, these patterns (which can be beautifully intricate and precise) are used for four main tasks:
to find text within a larger body of text;
to validate that a string conforms to a desired format;
to replace text (or insert text at matched positions, which is the same process);
and to split strings.