Explain the meanings of some of the regular expressions.

Data Structure AlgorithmsComputer ScienceComputers

Regular expression is the language which is used to describe the language and is accepted by finite automata. Regular expressions are the most effective way to represent any language. Let Σ be an alphabet which denotes the input set.

The regular expression over Σ can be defined as follows −

  • Φ is a regular expression which denotes the empty set.
  • ε is a regular expression and denotes the set { ε} and it is called a null string.
  • For each ‘a’ in Σ ‘a’ is a regular expression and denotes the set {a}.
  • If r and s regular expressions denoting the language.
    • L1 and l2 respectively then,
    • r+s is equivalent to L1 U L2 union
    • rs is equivalent to L1L2 concatenation
    • r* is equivalent to L1* closure

The r* is known as Kleen closure or closure which indicates occurrence of r for an infinite number of times.

Some of the regular expressions and their meanings are as follows −

  • (a+b)*

Meaning − Set of strings of a’s and b’s of any length including the NULL string.

  • (a+b)*abb

Meaning − Set of strings of a’s and b’s ending with string abb.

  • ab(a+b)*

Meaning − Set of strings of a’s and b’s starting with string ab.

  • (a+b)*aa(a+b)*

Meaning − Set of strings of a’s and b’s having a substring aa.

  • a*b*c*

Meaning − Set of strings consisting of any number of a’s followed by any number of b’s followed by any number of c’s.

  • aa*bb*cc*

Meaning − Set of strings consisting of at least one a’s followed by string consisting of at least one b’s followed by string consisting at least one c.

  • (a+b)*(a+bb)

Meaning − Set of strings of a’s and b’s ending with either a or bb.

  • (aa)*(bb)*b

Meaning − Set of strings consisting of an even number of a’s followed by an odd number of b’s.

  • (0+1)*000

Meaning − Set of strings of 0’s and 1’s ending with three consecutive zero’s.

  • (11)*

Meaning− Set consisting of an even number of 1’s.

raja
Published on 12-Jun-2021 10:16:21
Advertisements