const re = /[0-9]/g;
const data = ["12", "12", "12", "12", "12"].filter(i => re.test(i));
console.log(data);
//[ '12', '12', '12', '12' ]
JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., /foo/g or /foo/y). They store a lastIndex from the previous match. Using this internally, test() can be used to iterate over multiple matches in a string of text (with capture groups).