# What is the regular expression (RE) for the language of all those strings starting with aa and ending with ba? Defined over ∑={a,b}

Accepted Strings:

These all strings are the part of the language so should be accepted by regular expression;

Example strings = {aaba, aaaba, aabba, aaabba, aababa,………}and all other strings that can start with aa and end with ba.

Rejected Strings:

These all strings are not part of the language so should be rejected by regular expression.

Example strings = {a, b, ab, ba, aab, bba, abba,……………..} and all other strings that can’t start with aa or can’t end with ba.

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

 Part 1 Part 2 Part 3 aa (a+b)* ba

Explanation:

Part 1:

We are bounding the machine to always get aa when the machine starts generating any string from the regular expression. aa is the must for the machine to read at the start.

Part 2:

We are bounding the machine to always get (a+b)*  when the machine starts generating any string from the regular expression. aa is the must for a machine to read at the start and then machine reads (a+b)*

Plus symbol(+) representing the or(option). It means that machine can read a or machine can read b multiple times. * represents that machine can read multiple times a or b or null.

Part 3:

We are bounding the machine to always ba at the last.  When machine generates a string from the R.E, then machine enter first in part 1, then in part 2 and finally, machine enter in part 3 and must read ba.

Practice:

Now lets practice that how the string can be generated. Please follow the colors;

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

Strings: aaba, aaaba, aabba, aaaaba, aabbba, aaaababba, aabbaabababa,…………..

Regular expression (RE) for the language of all those strings starting with aa and ending with ba

## 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.