string between parentheses with regex
This question already has an answer here:
你需要使用捕获正则表达式组()
来分别提取数字和字符串,看看:
let rawStr = "this is (131PS) for now";
let theMatch = rawStr.match(/((d+)([A-Z]+))/);
if (theMatch) {
let theNum = parseInt(theMatch[1]);
let theString = theMatch[2];
console.log(theNum, theString);
}
链接地址: http://www.djcxy.com/p/76802.html
下一篇: 括号与正则表达式之间的字符串