Skip to content

fix(sed): support backreferences in search patterns#1246

Merged
chaliy merged 2 commits intomainfrom
fix/issue-1159-sed-backreferences
Apr 13, 2026
Merged

fix(sed): support backreferences in search patterns#1246
chaliy merged 2 commits intomainfrom
fix/issue-1159-sed-backreferences

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 13, 2026

Summary

  • Add fancy-regex as fallback for sed patterns containing backreferences (\1-\9) in the search side
  • The standard regex crate doesn't support backreferences in patterns; fancy-regex does
  • Transparent SedRegex wrapper tries regex first, falls back to fancy-regex only when backreferences are detected
  • No performance impact for patterns without backreferences (still uses fast regex crate)

Test plan

  • Unit test: search-side backreference matching repeated characters (\(.\)\1)
  • Unit test: HTML tag stripping with backreference in search pattern
  • All 24 existing sed unit tests pass (no regression)
  • All 15 spec test suites pass
  • cargo clippy clean, cargo fmt applied

Closes #1159

chaliy added 2 commits April 13, 2026 09:57
The `regex` crate doesn't support backreferences (\1-\9) in search
patterns. Add `fancy-regex` as fallback: try standard regex first,
detect backreference errors, fall back to fancy-regex which supports
them. Wraps both in SedRegex enum for transparent usage.

Closes #1159
@chaliy chaliy merged commit f102eaf into main Apr 13, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1159-sed-backreferences branch April 13, 2026 11:33
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.

fix(sed): backreferences in search pattern fail (\1 in match side)

1 participant