-3

Regular language given by its description:

The set of all strings of {0,1, a}, which contain the substring '01a' and an even number of '1'. For example, '01a1 ', '101a', '101a101'.

How to construct a regular expression that specifies the language?

  • Hint: It'd be easier to institute two checks: one to make sure that the string contains the characters you want and another to make sure that `1` appears an even number of times. –  Aug 25 '12 at 06:39
  • Sounds like homework. If so, please tag. – Matthias Aug 25 '12 at 06:42

1 Answers1

1

a oneliner for the heck of it:

^([0a]*1[0a]*([0a]*1[0a]*1)*)01a([0a]*1[0a]*1)*|([0a]*1[0a]*1)*01a([0a]*1[0a]*([0a]*1[0a]*1)*)$

basically, it checks for

string with odd number of 1s + 01a + string with even number of ones

OR

string with even number of 1s + 01a + string with odd number of ones

staafl
  • 3,147
  • 1
  • 28
  • 23