1

I'm asked to write a regex that accepts the complement of another given regex:

(a*b*)*

This regex seems to accept every single string on the alphabet consisting of {a, b}, so I believe that its complement must accept no strings at all on this alphabet.

How can this be expressed as a regex? Is it possible?

  • 1
    This question should probably go to StackOverflow. Although regular expressions are technically theoretical computer science, this is more appropriate there because you're asking for an example regular expressions instead of studying the properties of regular expressions. By the way, it's probably [^ab]* – Larry B. Oct 05 '18 at 17:49
  • If you are talking about regular expressions in the sense of formal languages (rather than the more general forms), then besides the operators (concatenation, alternative, Kleene star) their definition generally includes constants for the empty language (usually $\emptyset$ or $0$) and the empty word (usually $\epsilon$ or $1$). If your definition has these, the answer is trivial. – Klaus Draeger Oct 05 '18 at 21:35

0 Answers0