Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

replace not always working when regex string contains non-alphanumeric characters (Programmatic Usage)) #55

Open
ArnaudHambenne opened this issue Dec 8, 2015 · 1 comment

Comments

@ArnaudHambenne
Copy link

Hi,
First of all thanks for making this useful package, I have been using it extensively ever since I found it.
This extensive use has uncovered an issue for me that I would like to share. I noticed that when I used the programmatic usage like so:
replace({ regex: "foo", replacement: "bar", paths: ['.'], recursive: true, silent: true, });
'foo' did not get replaced by 'bar' when 'foo' contained (in my case) the characters : + ( ) even through the file contained the exact same string (it was a Date().toString() object with spaces replaced with underscores). Replacing these four characters with an underscore made it work again (granted it still matched the file string of course). I'm not entirely sure which one of the four provided made it fail, or whether it was all four, but I can imagine there could be other characters that cause this issue to happen too.
I hope this was helpful,
Arnaud

@shubhamjain23
Copy link

This is also happening to me, with '?'. Can you tell me how do you replace strings containing these characters?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants