Compile regex pattern with caching. Args: pattern: Regex pattern string Returns: Compiled regex pattern
(pattern: str)
| 13 | # Cache compiled regexes (max 128 patterns) |
| 14 | @lru_cache(maxsize=128) |
| 15 | def compile_regex(pattern: str) -> re.Pattern: |
| 16 | """Compile regex pattern with caching. |
| 17 | |
| 18 | Args: |
| 19 | pattern: Regex pattern string |
| 20 | |
| 21 | Returns: |
| 22 | Compiled regex pattern |
| 23 | """ |
| 24 | return re.compile(pattern, re.IGNORECASE) |
| 25 | |
| 26 | |
| 27 | class RuleEngine: |