Regular Expression

From Conservapedia

A regular expression is used in computer software to define a sequence of characters.[1]

In general, any character will match itself, but there are a dozen special characters, including the escape character.

To match any of 2 or more characters, enclose them in square brackets. For example,

gr[ae]y


will match gray or grey.

A regular expression is matched from left to right and is processed one token at a time. Certain characters have special meanings within the description of a regular language:

There also exists a wide range of special character classes distinguished with a backslash (a small list):


Regular expressions have also been extended by many languages, some of which extend them to the point where they are able to match a wider range of languages than is specified by a regular language.

Examples[edit]

Formal definition and Limitations[edit]

A regular expression is particular instance of a non-deterministic finite state automaton. Regular expressions are a type-3 grammar in the Chomsky hierarchy of language.

A regular expression is not able to count. This is because there is a finite number of states. Consider the language that is specified by anban. Examples of this language include b, aba, aabaa, aaabaaa, etc... A regular expression - being a finite state automaton itself - has a finite number of states that it can be in. If there a point at which the state loops back on itself it is no longer able to match that language.

See also[edit]

Further reading[edit]

  1. "A regular expression, or regex for short, is a pattern describing a certain amount of text." Regular Expression Quick Start

Categories: [Computer Science] [Language]


Download as ZWI file | Last modified: 02/24/2023 08:31:47 | 23 views
☰ Source: https://www.conservapedia.com/Regular_expression | License: CC BY-SA 3.0

ZWI signed:
  Encycloreader by the Knowledge Standards Foundation (KSF) ✓[what is this?]