Regular expression

1. (regexp, RE) One of the wild card patterns used by Perl and other languages, following Unix utilities such as grep, sed, and awk and editors such as vi and Emacs. Regular expressions use conventions similar to but more elaborate than those described under glob. A regular expression is a sequence of characters with the following meanings (in Perl, other flavours vary):
An ordinary character (not one of the special characters discussed below) matches that character.
A backslash (\) followed by any special character matches the special character itself. The special characters are:
“.” matches any character except newline; “RE*” (where the “*” is called the “Kleene star”) matches zero or more occurrences of RE. If there is any choice, the longest leftmost matching string is chosen.
“^” at the beginning of an RE matches the start of a line and “$” at the end of an RE matches the end of a line.
[CHARS] matches any one of the characters in CHARS. If the first character of the string is a “^” it matches any character except the remaining characters in the string (and also usually excluding newline). “-” may be used to indicate a range of consecutive ASCII characters.
(RE) matches whatever RE matches and \N, where N is a digit, matches whatever was matched by the RE between the Nth “(” and its corresponding “)” earlier in the same RE. Many flavours use \(RE\) instead of just (RE).
The concatenation of REs is a RE that matches the concatenation of the strings matched by each RE. RE1 | RE2 matches whatever RE1 or RE2 matches.
\ matches the end of a word. Many flavours use “\b” instead as the special character for “word boundary”.
REM matches M occurences of RE. REM, matches M or more occurences of RE. REM,N matches between M and N occurences. Other flavours use RE\M,N\.
Perl provides several “quote-like” operators for writing REs, including the common // form and less common ??.
A comprehensive survey of regexp flavours is found in Friedl 1997 (see below).
[Jeffrey E.F. Friedl, “Mastering Regular Expressions (, O’Reilly, 1997].
2. Any description of a pattern composed from combinations of symbols and the three operators:
Concatenation – pattern A concatenated with B matches a match for A followed by a match for B.
Or – pattern A-or-B matches either a match for A or a match for B.
Closure – zero or more matches for a pattern.
The earliest form of regular expressions (and the term itself) were invented by mathematician Stephen Cole Kleene in the mid-1950s, as a notation to easily manipulate “regular sets”, formal descriptions of the behaviour of finite state machines, in regular algebra.
[S.C. Kleene, “Representation of events in nerve nets and finite automata”, 1956, Automata Studies. Princeton].
[J.H. Conway, “Regular algebra and finite machines”, 1971, Eds Chapman & Hall].
[Sedgewick, “Algorithms in C”, page 294].


Read Also:

  • Regular expression converter


  • Regular fellow

    regular fellow

  • Regular flower

    regular flower A radially symmetric flower. In a regular flower, all of the members of a single whorl, such as the petals, are similar in shape and size. Lilies and the apple tree, for example, bear regular flowers. Compare irregular flower.

  • Regular graph

    mathematics A graph in which all nodes have the same degree. (1995-03-07)

Disclaimer: Regular expression definition / meaning should not be considered complete, up to date, and is not intended to be used in place of a visit, consultation, or advice of a legal, medical, or any other professional. All content on this website is for informational purposes only.