I’m sending a regex expression via JSON from my Ember front end to my Node server. When the regex expression is sent it is converted to a string. This is an example of what node receives:
{"find":{"name":"/^sp101/"},"sort":{"name":"1"},"limit":5}
In this example how do I convert find[‘name’] from a string to a regex? i.e. I want to extract /^sp101/ from find[‘name’] instead of “/^sp101/“
When I pass the string "/^sp101/" to a RegExp constructor it converts it to //^sp19// which I do not want.
Is there a way to accomplish this without using string manipulation? i.e. slicing off the first and last "/" before passing it to the constructor.