Backref $1 is inserted as literal text during a regex find/replace


During ‘find/replace’, the backref $1 is being inserted as literal text. I have the latest Atom installed, and regex is on. Tried in Latex and plain text syntax mode. Here’s my code:

typical example:  Find/Replace `some phrase' with ‘some phrase’
 `[\w ]+'

I want to replace the Latex quotes ` and ’ with unicode typographical quotes ‘ and ’. There’s an issue on GitHub relating to Atom’s Regex syntax where several uses report the same problem.

Regex in replace not working?

What if you place a capture in your regexp?

`([\w ]+)'


As @john indicated, you need to have a capture in the find field. From my response on the Issue:

  1. Open the atom/atom project in Atom
  2. Open the file
  3. Press Cmd+F to open the find-and-replace panel
  4. Ensure that Regular Expressions mode is turned on
  5. Enter ( in the find field
  6. Enter foo$1 in the replace field
  7. Click Find
  8. Click Replace

When you do this, the found instance of the text is replaced with However, if you enter without the parens in the fifth step, then the text is replaced with foo$1.

Verified this behavior using Atom v1.0.12-ad95281 on Mac OS X 10.10.5.


Thanks @john and @leedohm - temporary mental blindness, completely forgot to actually ‘capture’ anything!