micro-editor / micro-editor/micro

Have to double escape regexes when replacing

Open
#1,131 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
29.6k
Forks
1.4k
Avg merge
2d 18h
Merged PRs (30d)
10

Description

Description of the problem or steps to reproduce

When doing a find, a regex only needs single backslah characters to work, e.g. \b \w etc.
However when going a replace, you need to use double backslashes, e.g. \\b \\w etc.

E.g. Given the following file...

hello world

Ctrl-F \bhello successfully finds the "hello"
Ctrl-E replace \bhello goodbye does not find the "hello" (Displays the message Nothing matched bhello)
Ctrl-E replace \\bhello goodbye successfully finds the "hello" and replaces it with goodbye.

Specifications

Tried with both 1.40 and 1.41 nightly and both exhibit the same behaviour

Version: 1.4.0
Commit hash: af520cf
Compiled on January 26, 2018

Version: 1.4.1-71
Commit hash: 91b6500
Compiled on June 07, 2018

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior in micro using Ctrl-F and Ctrl-E with the provided hello-world example. Trace the find and replace command entry points to compare how regex backslashes are handled. Done means replacement accepts the same single-backslash regex syntax as find while preserving the documented replacement behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.