Agent had problems trying to replace text containing `“Hi!”` curly quotes

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

  1. Create a text file containing “Hi!” (with Unicode curly quotes)
  2. Attempt to use search_replace with a regex-like pattern as the old_string, such as .*Hi!.*
  3. Set any new_string value (e.g., "Hello World")
  4. 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:
  1. Basic search_replace - Successfully replaced “Hi!” with "Hi!"
  2. search_replace with replace_all=true - Successfully replaced all occurrences
  3. Partial string replacement - Successfully replaced just Hi! with Hello!
  4. Full line replacement including newline - Successfully replaced “Hi!\n” with "Hi!\n"
  5. PowerShell command - Command executed but didn’t actually replace curly quotes (likely due to Unicode handling)
  6. grep search - Successfully found the pattern Hi! in the file
Methods that failed:
  1. sed command - Failed with exit code 1 (likely due to path or quote escaping issues)

  2. 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_replace tool 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

Hey, thanks for the report and the thorough testing.

This is expected behavior. The search_replace tool in Agent intentionally uses exact string matching, not regex. This is for reliability and predictable results.

As you found, exact matching works correctly even with Unicode curly quotes ("Hi!"). If you really need regular expressions, I’d suggest asking Agent to run terminal commands directly, like sed on Unix systems or PowerShell on Windows.

Your suggestion to show a clearer error message when the pattern looks like regex is a good idea for improving UX. I’ll pass this along to the team as feedback.

The problem came to light while running the Opus 4.5 Agent, and I don’t know how many dollars it would have spent trying to figure out what was going on if I hadn’t taken over.