A regular expression (or regex) is a string of characters, (some of which being reserved control characters,) which represent a pattern [1], i.e. a string designed to match a particular sequence of characters. Regular expressions provide the basic tool in searching, and are ubiquitous in the electronic world.
There are many editors with regex functionalities. Here are a few examples (Please feel free to add or remove if you find better ones.)
There are several "dialects" (e.g. javascript, perl, php, python) of regular exprssions which differ slightly in grammar. Let us focus on python regex for the moment (because I happen to have a reference [2] for it).
\-.*+?$<!=|()[]^:#
[please verify]
abcdefg
)which does not contain any control characters is trivially a regular expression ("regex") pattern. It matches only itself[A-Z]
matches a character between A and Z (in the ASCII table)\.
or even the backslash itself \\
, match the character itself (this pattern is called an "escape"). In our examples, \. matches the single dot . and \\ matches the backslash[A-Za-z0-9\-]
matches any single alphanumeric character or the dash "-".\n
matches a newlineabc.xyz
matches a string that starts with abc, then contains any character except an end-of-line character, then ends with xyza*
matches a string with as many characters "a" as possible; it also matches the empty string "".abc.*xyz
matches a string which starts and ends with "abc" and "xyz" respectively, and between which is the longest available string (which could be empty) of any character except the newline.[A-Za-z0-9\-]
?[proposals]