0
$\begingroup$

What is the difference between $(a|b)^\ast$ and $a^\ast b^\ast$? Can you show more examples of Kleene star and patterns and explain a little bit? I've searched so many sites in Google, but it returns very little results on this topic. I would be very grateful.

  • 0
    What is $(a\mid b)$?2012-02-02
  • 0
    @JavaMan: a, b or ab. Right?2012-02-02

1 Answers 1

9

Assuming that $|$ refers to an "or" selection (so the character can be either an $a$ or a $b$, then $(a|b)^*$ is all strings composed of the characters $a$ and/or $b$, including the empty string. On the other hand, $a^*b^*$ refers to all strings composed of the characters $a$ and/or $b$ which has all $a$'s preceding all $b$'s, again including the empty string.

For instance, $ababbbabab$ would be a member of $(a|b)^*$ but not $a^*b^*$, whereas $aaabbbbb$ would be a member of both.

  • 0
    Could you please give me a few more examples, I would really be grateful.2012-02-02
  • 1
    Unfortunately I don't know what kind of examples you want. If you do a search for Kleene star examples there are references all over the place. One in particular is http://www.csee.umbc.edu/portal/help/theory/lang_def.shtml. The Regular Language section contains some good examples/patterns.2012-02-02
  • 0
    Thanks, those example will be enough, I think I almost got it now.2012-02-02