What is the difference between the following regular expressions? (a U b)* and (ab)*
Difference between union and concatenation ? which of the above regex accepts strings in which 'a' is always before 'b' ?
Please clarify.. Thanks in advance.
Concatenation: If R1 and R2 are regular expressions, then R1R2 (also written as R1. R2) is also a regular expression. L(R1R2) = L(R1) concatenated with L(R2). Kleene closure: If R1 is a regular expression, then R1* (the Kleene closure of R1) is also a regular expression.
Concatenation. The concatenation of languages L and M, denoted L.M or just LM , is the set of strings that can be formed by taking any string in L and concatenating it with any string in M. Example. If L = {001, 10, 111} and M = {ǫ,001} then. L.M = {001, 10,111, 001001, 10001, 111001}
CONCATENATION is equivalent to UNION-ALL . This combines the input tables and returns all the rows. UNION combines the input tables.
Finite automata are formal (or abstract) machines for recognizing patterns. These machines are used extensively in compilers and text editors, which must recognize patterns in the input. Regular expressions are a formal notation for generating patterns.
(ab)* means zero of 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 is to add one set onto another. a* concat b* would be concatenating the sequence resulting from a* with the one resulting from b*, so:
<empty>, ab, aab, abb, aaaabbbb, bbbbb
Union is to combine two sets and results in the distinct results.So, a* U b* would be the regular expressions of zero or more instances of a and zero or more instances of b:
<empty>, a, aa, aaa, aaaa, b, bb, bbb, bbbb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With