Regular expression

Blue highlights show the match results of the regular expression pattern: /r[aeiou]+/g (lower case r followed by one or more lower-case vowels).

A regular expression (shortened as regex or regexp),[1] sometimes referred to as rational expression,[2][3] is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. Regular expression techniques are developed in theoretical computer science and formal language theory.

The concept of regular expressions began in the 1950s, when the American mathematician Stephen Cole Kleene formalized the concept of a regular language. They came into common use with Unix text-processing utilities. Different syntaxes for writing regular expressions have existed since the 1980s, one being the POSIX standard and another, widely used, being the Perl syntax.

Regular expressions are used in search engines, in search and replace dialogs of word processors and text editors, in text processing utilities such as sed and AWK, and in lexical analysis. Regular expressions are supported in many programming languages. Library implementations are often called an "engine",[4][5] and many of these are available for reuse.

  1. ^ Goyvaerts, Jan. "Regular Expression Tutorial - Learn How to Use Regular Expressions". Regular-Expressions.info. Archived from the original on 2016-11-01. Retrieved 2016-10-31.
  2. ^ Mitkov, Ruslan (2003). The Oxford Handbook of Computational Linguistics. Oxford University Press. p. 754. ISBN 978-0-19-927634-9. Archived from the original on 2017-02-28. Retrieved 2016-07-25.
  3. ^ Lawson, Mark V. (17 September 2003). Finite Automata. CRC Press. pp. 98–100. ISBN 978-1-58488-255-8. Archived from the original on 27 February 2017. Retrieved 25 July 2016.
  4. ^ "How a Regex Engine Works Internally". regular-expressions.info. Retrieved 24 February 2024.
  5. ^ Heddings, Anthony (11 March 2020). "How Do You Actually Use Regex?". howtogeek.com. Retrieved 24 February 2024.