Skip to content

Keep regex escapes intact in case-insensitive DeepSearch - #632

Open
x0Lazarus wants to merge 1 commit into
qlustered:devfrom
x0Lazarus:fix/preserve-search-regex-case
Open

x0Lazarus wants to merge 1 commit into
qlustered:devfrom
x0Lazarus:fix/preserve-search-regex-case

Conversation

@x0Lazarus

Copy link
Copy Markdown

DeepSearch lowercases a regular expression before using it for a case-insensitive search. That changes the meaning of escapes: searching for \S+ (non-whitespace) instead searches for \s+ (whitespace), and \D+ becomes a digit search.

Use re.IGNORECASE instead, keeping both the pattern and the searched text intact. This also preserves Unicode escapes and lets groups such as (?-i:ABC) keep their explicitly case-sensitive behavior. Literal searches and the flags of precompiled patterns retain their existing behavior. This addresses the problem also described in the closed PR #631.

The search tests pass all 78 cases, including regressions for escaped characters, dictionary paths, scoped flags, and compiled patterns. Pyright reports no errors for the changed module. On Windows with Python 3.12, the broader run passes 1,319 tests with 8 skips and one failure in test_delta_dump_and_read3; that same text-mode pickle failure occurs on unchanged dev. The security test module and two restricted-pickle tests were excluded from this local run. Other operating systems and Python versions have not been tested locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant