我使用asp.net核心mvc,当从bakend接收字符串时,我需要截取它,因为我想向视图显示预期的字符串(B0ERO49J67SFK)。
Indoland--Detachable/B0ERO49J67SFK/ref=_arp_d_rvw_fmt?ie=UTF8&formatType=current_format如何编写正则表达式来截取此字符串。
var regex = //0-9{13}/g;
上面的正则表达式是I wittend,但它得到的是null,无法截获正确的字符串。
发布于 2021-03-10 21:46:11
你可以使用不正确的正则表达式,关于jquery正则表达式,你可以试试这个例子。
var str="Husband-Pillow-Detachable-Removable-Adjustable/B0ERO49J67SFK/ref=cm_cr_arp_d_rvw_fmt?ie=UTF8&formatType=current_format";
var result=/(?<=\/)[0-9A-Z]{13}(?=\/)/.exec(str);
console.log(result);https://stackoverflow.com/questions/66564344
复制相似问题