into a regular expression (handling special characters) or 2) by enclosing
a (non-capturing) group if
inputalready is a regular expression.
1) When concatenating a non-regex package component (like “org.google”) with a regex
component (like “[^.]+”) the other component has to be converted into a regex too, see
2) The grouping is strictly necessary if a)
input is a regular expression that b)
contains the alteration character (‘|’) and if c) the pattern is not already enclosed in a
group – as you see in this example:
parent="com|org", child="common|uncommon" will
result in the pattern
"(?:org|com).(?common|uncommon)" what will match
"org.uncommon". Without the grouping it would be
"uncommon", which clearly is
undesirable. Adding the group fixes this.
For simplicity the grouping is added to regular expressions unconditionally.
Read more here: Source link