Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

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

Last modified on May 27th, 2018 at 9:45 am

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 1Part 2Part 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

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,…………..

Topic Covered 

Rregular expression (RE) for the language of all those strings starting with aa and ending with b.
  List of All Regular Expression examples : Click Here 
.

Pr. Fazal Rehman Shamil
Publisher of Internatonal Journal of Software Technology & Science ISSN: 2616- 5325
Instructor, Researcher,SEO expert, Web Master, Article Writer and Poet. Feel free to contact.