adamreisnz / replace-in-file

A simple utility to quickly replace contents in one or more files
580 stars 65 forks source link

Added Regex type 'To' type so that both from and to string can be regex #188

Closed twok020101 closed 3 months ago

twok020101 commented 7 months ago

In typescript 'to' parameter was restricted to only string, but in general this works very well with RegExp as well. This is edited and used in one of my projects. This resolves #166 (Same person with different account)

adamreisnz commented 7 months ago

Thanks for the PR, can you elaborate a bit more on how that would work, using a RegEx as a replacement? How does that work?

According to the documentation, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace, the replace function only seems to accept a string or a function.

Can you give me a code example of how this would be used so I can test it out?