const input = [
{q: "58b988ff62279282090dd314"},
{q: "58b988ff62279282090dc152"},
{q: "58b988ff62279282090dbf09"}
];
input.forEach(({q}) => $(`[data-id="${q}"]`).css("background", "lime"));
How can i validate on (q) value Regular expression ?
I want use regex code in this way because my value it's always changing.
Meanwhile I am using that code on Greasemonkey.
{q: "5..........................bf09"}
It appears that you want to apply a regex which checks that the q
value starts with 5
and ends with bf09
. I don't know how to phrase this without using an explicit anonymous function:
input.forEach(function(element) {
if (element.match(/^5.{19}bf09$/)) {
$(`[data-id="${element}"]`).css("background", "lime"));
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.