Automata Regular Expression - The Difference Between Concatenation and Combining

What is the difference between the following regular expressions? (a U b) * and (ab) *

The difference between concatenation and union? which of the above regular expression accepts lines in which "a" is always before "b"?

Please explain .. Thanks in advance.

+4
source share
1 answer

(ab) * means zero more instances of the sequence ab. For example,

<empty>, ab, abab, ababab

Consider a * and b * :

a*: <empty>, a, aa, aaa, aaa, ...
b*: <empty>, b, bb, bbb, bbb, ...

Concatenation - add one set to another. a * concat b * will concatenate the sequence obtained from a * with that obtained from b *, therefore:

<empty>, ab, aab, abb, aaaabbbb, bbbbb

Union . , a * U b * a b:

<empty>, a, aa, aaa, aaaa, b, bb, bbb, bbbb
+2

Source: https://habr.com/ru/post/1611975/


All Articles