File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
src/guardrails/checks/text Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ def _compile_pattern(keywords: tuple[str, ...]) -> re.Pattern[str]:
8181 # Check first and last character of the original keyword for word character status
8282 starts_with_word_char = keyword and keyword [0 ].isalnum () or (keyword and keyword [0 ] == "_" )
8383 ends_with_word_char = keyword and keyword [- 1 ].isalnum () or (keyword and keyword [- 1 ] == "_" )
84-
84+
8585 prefix = r"(?<!\w)" if starts_with_word_char else ""
8686 suffix = r"(?!\w)" if ends_with_word_char else ""
8787 patterns .append (f"{ prefix } { escaped } { suffix } " )
88-
88+
8989 # (?<!\w) and (?!\w) emulate Unicode-aware word boundaries (letters, digits, underscore).
9090 pattern_text = "(?:" + "|" .join (patterns ) + ")"
9191
You can’t perform that action at this time.
0 commit comments