我有一个字符串,它是通过以下方式构造的:
const string = `text which is always the same.
values: [${someArray.join(",")}, oneMore]
more text which is always the same.
other values: [${otherArray.map(someValue => "someLabel" + someValue).join(",")}, oneMore]`
Now I wish to extract all the someValue
s from an already constructed string (in Javascript).
someArray
andotherArray
can be of arbitrary lengthsomeArray
andotherArray
contain arbitrary alphanumeric strings
我不知道该如何处理。我应该使用正则表达式,还是有更好的方法呢? 如果是前者,我将不胜感激一些以前做过类似事情的例子。