-1

I Want to Create Regular Expression from string of {a,b} that it contains neither the substring ab NOR ba?How I can do it?

Raphael
  • 72,336
  • 29
  • 179
  • 389
hanie
  • 1

1 Answers1

0

If a string over $\{a,b\}$ contains neither $ab$ nor $ba$ as a substring, then all of its letters must be the same (why?). You can use this to create a regular expression for the language of all such strings.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503