I have the following string:
// const asdf = 'asdf'
// // comment
// const asdf2 = asdf
And I want to run a regexp replace to make it look as follows:
const asdf = 'asdf'
// comment
const asdf2 = asdf
Basically, I'm trying to make a regexp that will comment out the first instance of //
on every line. Here is my current implementation:
(setq comment "// const asdf = 'asdf'\n// // comment\n// const asdf2 = asdf")
(setq comment (replace-regexp-in-string "\\(//\\)" "" comment)))
But note that it is removing all matches to //
, which gives the following output:
const asdf = 'asdf'
comment
const asdf2 = asdf
But I want to leave the second instance of //
on the // // comment
line. Any suggestions?
If your are curious, I am trying to solve this issue: https://github.com/fxbois/web-mode/issues/980 at this place in the code of web-mode: https://github.com/fxbois/web-mode/blob/master/web-mode.el#L9973
uncomment-region
be better for this?