Regular Expression
Regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters.
Regular expressions (abbreviated as regex or regexp) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.
A regular expression is an expression that describes a set of strings.
It is composed of Symbols and Operators.
A regular expression over S is an expression formed using the following rules:
The symbol Φ is a regular expression
The symbol ε is a regular expression
For every a E Σ, the symbol a is a regular expression
If R and S are regular expressions, so are RS, R+S and R*.
Examples
01* = {0, 01, 011, 0111, ...}
(01*)(01) = {001, 0101, 01101, 011101, ...}
(0+1)*
(0+1)*01(0+1)*
((0+1)(0+1)+(0+1)(0+1)(0+1))*
((0+1)(0+1))*+((0+1)(0+1)(0+1))*
(1+01+001)*(ε+0+00)
Click here to view the Regular expressions converted to Finite State Machines