DEV Community

loading...

Discussion on: How YOU can learn enough RegEx in JavaScript to be dangerous

Collapse
miketalbot profile image
Mike Talbot

I know that pain (and I've bookmarked this article for the next time I feel it!)

The only thing I'd point out is that in your example of making a regex at the top using the constructor you are using a regex as the parameter - I'd say the real benefit of the constructor version is that it can take a plain string - not only an existing regex. Also it's new RegExp() in JS.

     const myRegex = new RegExp(`(${magicWord})|(blah)`, 'i')
Collapse
softchris profile image
Chris Noring Author

hi Mike. Thanks for the feedback.. Yea definitly, it needs escape signs though, so it's not 1-1 replacement. I learned that the hard way :)

Collapse
qm3ster profile image
Mihail Malo

And you can use a regex to do it :D

Forem Open with the Forem app