I want to make an input where users can write a custom regex in literal notation. I then want to create a RegExp out of that literal notation string.
Something like this:
const literalNotationStr = `/literal/i`;
const regex = makeRegexFromLiteralNotationString(literalNotationStr)
function makeRegexFromLiteralNotationString(str: string): RegExp {
// ... magic code ...
}
Is there a function I'm missing here or is this the kind of thing where you have to parse and build yourself?