# Regular expression for the language of even length strings starting with a and ending with b in theory of automata

Regular expression for the language of even length strings starting with a and ending with b.

Accepted Strings:

All strings of the following pattern should be accepted by RE.

ab, aab, abb,abab,……

Reject strings:

All strings of the following pattern should be rejected by RE.

a, b, ba, aa, bb, ba,bba,……

R.E = a (aa+bb+ab+ba)* b

## Regular expression for even number of a’s defined over {a,b}

regular expression for even number of a’s is (b|ab*ab*)*.

Valid strings: aa, aba, aab, aaaab, aaaba, aabaa, abaaa, baaaa,…. and many other similar strings.

Invalid strings: ab, ba, aaa, aaab, aaba, aaba, abaa, baaa,…. and many other similar strings.

## A regular expression for the language of all those strings having just ab or if string size is greater than 2, then starting with ab and ending with b and having even length strings

ab+ab(a+b)((a+b)(a+b))*b

## A regular expression for the language of all those strings starting with ab and ending with b and having even length strings

ab(a+b)((a+b)(a+b))*b

## Regular expression for even number of b’s defined over {a,b}

regular expression for even number of b’s is (a|ba*ba*)*.

## All strings having at least two occurences of the substring 00

((1 + 0)*00(1 + 0)*00(1 + 0)*)+

Valid strings: 0000, 10000, 00001, 100100, 110000, 000011, …. and many other similar strings.

Invalid strings: 0, 00, 01,  10,  001, 100, 0100, 1000, 00000, 1000, 0001, 10100, 11000, 00011, …. and many other similar strings.

## Tutorial: Regular Expression

A detailed tutorial of the regular expression is here in the link of regular expression tutorial. This page contains the practice questions of regular expressions with solutions.

Tutorial covering the topics

• Give a regular expression.
• Describe the strings of the regular expression.
• write a regular expression.
• create all strings from regular expression.
• Generate all strings from regular expression.
• Extract all strings from regular expression.
• Find all strings from regular expression.
• Examples of regular expression.