简体   繁体   English

Automata正则表达式 - 连接和并集之间的区别

[英]Automata Regular expression - difference between concatenation & union

What is the difference between the following regular expressions? 以下正则表达式之间有什么区别? (a U b)* and (ab)* (a U b)*和(ab)*

Difference between union and concatenation ? 联合和连接之间的区别? which of the above regex accepts strings in which 'a' is always before 'b' ? 以上哪个正则表达式接受'a'总是在'b'之前的字符串?

Please clarify.. Thanks in advance. 请澄清..提前致谢。

(ab)* means zero of more instances of the sequence ab. (ab)*表示序列ab的更多实例为零。 For example, 例如,

<empty>, ab, abab, ababab

Consider a* and b* : 考虑一个*和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: a * concat b *会将a *产生的序列与b *产生的序列连接起来,所以:

<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: 联合是组合两个集合并产生不同的结果。因此,a * U b *将是零的一个或多个实例以及零个或多个b实例的正则表达式:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM