MCPcopy
hub / github.com/anthropics/claude-code / _regex_match

Method _regex_match

plugins/hookify/core/rule_engine.py:256–273  ·  view source on GitHub ↗

Check if pattern matches text using regex. Args: pattern: Regex pattern text: Text to match against Returns: True if pattern matches

(self, pattern: str, text: str)

Source from the content-addressed store, hash-verified

254 return None
255
256 def _regex_match(self, pattern: str, text: str) -> bool:
257 """Check if pattern matches text using regex.
258
259 Args:
260 pattern: Regex pattern
261 text: Text to match against
262
263 Returns:
264 True if pattern matches
265 """
266 try:
267 # Use cached compiled regex (LRU cache with max 128 patterns)
268 regex = compile_regex(pattern)
269 return bool(regex.search(text))
270
271 except re.error as e:
272 print(f"Invalid regex pattern '{pattern}': {e}", file=sys.stderr)
273 return False
274
275
276# For testing

Callers 1

_check_conditionMethod · 0.95

Calls 1

compile_regexFunction · 0.85

Tested by

no test coverage detected