how to put regex pattern as string in array of object? below code won't work, I think I'm missing some escape string
const arr = [{
description: "(0-9)",
pattern: "(?=.*d)",
}]
const result = arr.map(x => new RegExp(x.pattern).test(10));
console.log(result) //expect true
demo https://codesandbox.io/s/javascript-forked-ttuyp?file=/index.js
CodePudding user response: