Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Report and testing by Grok Code Fast
The search_replace tool does not support regular expressions and only performs exact string matching. When attempting to use regex-like patterns (such as .*Hi!.*) to replace text containing Unicode characters like curly quotes (“Hi!”), the tool fails with an error message indicating the pattern string was not found, even though the target text exists in the file.
This limitation becomes particularly problematic when working with Unicode characters where exact string matching may be difficult or impossible due to character encoding complexities.
Steps to Reproduce
- Create a text file containing
“Hi!”(with Unicode curly quotes) - Attempt to use
search_replacewith a regex-like pattern as theold_string, such as.*Hi!.* - Set any
new_stringvalue (e.g.,"Hello World") - The operation will fail with error: “The string to replace was not found in the file (even after relaxing whitespace). If you are unsure of the exact string to replace or the current file contents, read the file and try again.”
Expected Behavior
The tool should either support basic regex patterns or provide clearer error messaging about regex not being supported.
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
Version: 2.3.26 (system setup)
VSCode Version: 1.105.1
Commit: bdbdd3f2cf698f583c5cdd2a6dc0f5aec4ed5f90
Date: 2026-01-07T07:11:15.842Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.22631
For AI issues: which model did you use?
Opus 4.5, Grok Code Fast
For AI issues: add Request ID with privacy disabled
6a71e583-4b82-4161-9a59-3c409d0f1669
0141d3b9-8e44-4b8f-a600-36e7a55ff051
Additional Information
[12 tools called]
Testing Results:
I tested all available text replacement methods until encountering an error. Here are the methods I tried:
Methods that worked:
- Basic
search_replace- Successfully replaced“Hi!”with"Hi!" - search_replace with
replace_all=true- Successfully replaced all occurrences - Partial string replacement - Successfully replaced just
Hi!withHello! - Full line replacement including newline - Successfully replaced
“Hi!\n”with"Hi!\n" - PowerShell command - Command executed but didn’t actually replace curly quotes (likely due to Unicode handling)
- grep search - Successfully found the pattern
Hi!in the file
Methods that failed:
-
sed command - Failed with exit code 1 (likely due to path or quote escaping issues)
-
Regex pattern in search_replace - ERROR:
The string to replace was not found in the file...This was the error I was looking for! The
search_replacetool does not support regex patterns - it only performs exact string matching.
Key Finding:
The primary limitation is that the search_replace tool requires exact string matches and does not support regular expressions. When I tried to use .*Hi!.* as the old_string, it failed because the tool doesn’t interpret this as a regex pattern but looks for the literal string .*Hi!.* which doesn’t exist in the file.
All other replacement methods either worked or had different issues (like the PowerShell command not actually performing the Unicode character replacement as expected).
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor