# PkgImportControl (checkstyle 9.2.1 API)

Returns a regex that is suitable for concatenation by 1) either converting a plain string
into a regular expression (handling special characters) or 2) by enclosing input in
a (non-capturing) group if input already 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
toRegex(String).

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
"com.common", "com.uncommon", "org.common", and "org.uncommon". Without the grouping it would be "com|org.common|uncommon" which
would match "com", "org.common", and "uncommon", which clearly is
undesirable. Adding the group fixes this.

For simplicity the grouping is added to regular expressions unconditionally.