Group regex within anchoring

This ensures that anchoring will apply to the entire anchored expression, eg. a pattern like `foo|bar` will only match the strings "foo" and "bar" (`^(?:foo|bar)$`), instead of matching any string that begins with "foo" or ends with "bar" (`^foo|bar$`).
This commit is contained in:
Stuart P. Bentley
2020-10-10 15:47:38 -07:00
committed by GitHub
parent 1971816663
commit 3c8e6d7151

View File

@@ -514,7 +514,7 @@ func anchorRegex(pattern string) string {
if pattern == "" { if pattern == "" {
return pattern return pattern
} }
return "^" + pattern + "$" return "^(?:" + pattern + ")$"
} }
// Select returns a list of resources that // Select returns a list of resources that