There are only 6 characters in the length, and the\ sign is not counted. Is there any way to do that?

strings in regular format are ignored

I want to get rid of the internal regularity of head and tail / and use new RegExp () to get a regular object, but\ is ignored, so my regularity is always wrong.

hopes to achieve something like this. For "/ ^ d $/", you can get "^\ d$" for "/ ^ d $/ ig", and "^\ d$" and "ig" for "/ ^ d < / d$ > $/ ig", but the\ sign is ignored, which is a bit of a headache.

May.08,2021


es6:

var res = String.raw`"/^\d*$/ig"`.match(/\/(.*)\/(.*)/);
console.log(res[1],res[2]); //^\d*$ ig

if you are in a variable, it is estimated that you can only write a map to write all the current escape lists and then replace them.

Menu