(a ∪ b)*
∪ (a*)
Edit:∪代表工会
您是对的。
(a ∪ b)*.
可以匹配A和B的任何字符串,因此可以匹配,因此它们是等效的。 (a*b*)*
相交(a U b)*
是IS(a U b)*
a*
a*
的子集。因此,可以将整个表达式简化为
a*
。
(a*b*
)+a
* =(a+b)*
using(a+b)*=(a
* b)* a*
我们可以写(a* b)* a* + a*
(a* b)* + epsilon)a* 等于(a
* b)* a* i.e(a+b)*真正的含义是(从
Herey复制)
(a U b)*
目前,该表达式与所有这些序列匹配:(a U b)*
(看
) 没有删除捕获的组和剩余的字母顺序,因此无法简化这一点。
Edit:如果在您的正则语句中代表“联合”,则此表达式无效。不可能在正则没有任何东西。只有NODE EXPLANATION
--------------------------------------------------------------------------------
( group and capture to \1 (0 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
( group and capture to \2:
--------------------------------------------------------------------------------
a* 'a' (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
) end of \2
--------------------------------------------------------------------------------
( group and capture to \3:
--------------------------------------------------------------------------------
b* 'b' (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
) end of \3
--------------------------------------------------------------------------------
)* end of \1 (NOTE: because you are using a
quantifier on this capture, only the LAST
repetition of the captured pattern will be
stored in \1)
--------------------------------------------------------------------------------
U 'U'
--------------------------------------------------------------------------------
( group and capture to \4:
--------------------------------------------------------------------------------
a* 'a' (0 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
) end of \4
(管道)。如果您想结合
abUa bU U aabbUaa aaUaa aaU Uaa bbU ababUaa aabbaabbUaa
和U
,那么它可能是OR
,但它仍然会匹配类似的东西。
,因为,在您的正则语句中捕获组是没有用的,因此类似的东西足以匹配任何数量的
|
和((a*)(b*))*
's.s。