phitranphitranphitran / regexp-saver

VSCode extension for saving and re-using regular expressions
https://marketplace.visualstudio.com/items?itemName=phi.regexp-saver
MIT License
8 stars 2 forks source link

New Line replacement does not happen #17

Open daniele-aveta opened 7 months ago

daniele-aveta commented 7 months ago

I'm using regExp Saver v1.1.0 on VS Code 1.88.1 on Windows 10 and whenever I try to replace a new line with something, the extension just adds the replacement string without getting rid of the new line.

Here is my settings.json

{
    "label": "test",
    "regExp": "\\n",
    replacePattern": " "
}

I've tried executing the regex with VS Code's replacement tool, and it provides the expected behavior.

Replacing \n with a space

test
test

Expected output

test test

Actual output

test
 test
phitranphitranphitran commented 7 months ago

I just tried to reproduce your issue but couldn't. I added the same object to my settings.json and the newline was successfully replaced. Both when using Replace In File and Replace In Selection.

Could you give any more details that could help?

phitranphitranphitran commented 7 months ago

Hmm, I am using mac OS, maybe that has something to do with it

daniele-aveta commented 7 months ago

Would it be possible for you to test it in a container or a VM?

duwejeferson commented 4 months ago

Indeed, the line breaks are not being replaced, it's happening to me too. An old regex i had saved is not working anymore. The one detailed here #12.

When doing some tests, replacing \n with spaces, as the Issues states, the line breaks are preserved, and the spaces are added.

VS Code (1.90.2) on Windows 11 and on Ubuntu WSL have the same behavior.

EDIT: Using the option "Find in File", where the regex is applied on VS Code's Find and Replace box works properly.