Search code examples
automata

About Regular Expression


Set={a,b} and L7:"All words that begin with an a and end with a b" is given L7 can be defined by

a(a+b)*b

What is the meaning of "+" ? And, How to solve this problem ?


Solution

  • a       # first letter is always 'a'
    (a+b)*  # zero or more sequence of letters 'a' or 'b' [one letter at time]
    b       # last letter is always 'b'
    

    Here + means or and then consequently, we have the below results:

    ab
    abb
    abbb
    aaab
    abbbb
    aaaab
    abbbbb
    aaaaab
    .....