Regular expressions

Regular expressions

A regular expression is another way of describing a set. Regular expressions allow particular types of languages to be described in a convenient shorthand notation.

Regular expressions symbols

Regular expressions use metacharacters. The most common metacharacters are:
* (0 or more repetitions)
+ (1 or more repetitions)
? (0 or 1 repetitions, ie optional)
| (alternation, ie or)
( ) to group regular expressions
{x} (to specify a certain number of an item)
[0-9] (to define a digit)
[A-Z] (to define a character from the uppercase alphabet)

Regular expressions examples



Regular expressions and FSMs

Regular expressions and FSMs are equivalent ways of defining a regular language.



Regular languages

A language is called regular if it can be represented by a regular expression. Therefore, a regular language is any language that a FSM will accept.

Knowledge check


Questions:
Correct:

Question text


© All materials created by and copyright S.Goff