Often, we see regex patterns that use alternation, and around the alternation, we use anchors or boundary matchers without safeguarding the alternation expression in a group. Note that the ^, $, A, , z anchors and the boundary matcher have a higher precedence than the alternation character, | (pipe)
So, consider a regular expression written as follows:
^com|org|net$
It will also match computer, organization, and internet, though the intent probably was to match only com, net, and org. This is because the start anchor, ^, is being applied to com only and the end anchor, $, is being applied to net, whereas org is not anchored at all.
This regular expression should be written as follows to match only com, org, and net correctly:
^(?:com|org|net)$