Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.
This repository was 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

@ArnaudHambenne

Description

@ArnaudHambenne

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions