示例字符串: This is an inactive AAAAA product. It will be AAAAAA by AAAAA test1/test2 number ABCDEF123456/123456789 during execution
我需要将这些值分开并将其存储在一个数组中“ ABCDEF123456/1234567890
”这些值将在一个数组中[ABCDEF123456,1234567890].
Var str ="This is an inactive AAAAA product. It will be AAAAAA by AAAAA test1/test2 number ABCDEF123456/123456789 during execution";
var splitStr = str.split("/");
console.log(splitStr[1]); // ABCDEF123456
在这里我得到“ ABCDEF123456
”
我需要才达到像ABCDEF123456/1234567890
会[ABCDEF123456,1234567890]
您可以使用match
和split
let str = `Text1/Text2 This is an inactive AAAAA product. It will be AAAAAA by AAAAA test1/test2 number ABCDEF123456/123456789 during execution`
let final = str.match(/(?<!\S)\w+\/\w+(?!\S)/g).map(v=> v.split('/'))
console.log(final)
如果你只是想喜欢的图案alphanumeric/numeric
替换第二\w+
通过\d+
let str = `Text1/Text2 This is an inactive AAAAA product. It will be AAAAAA by AAAAA test1/test2 number ABCDEF123456/123456789 during execution`
let final = str.match(/(?<!\S)\w+\/\d+(?!\S)/g).map(v => v.split('/'))
console.log(final)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句