&#34;我期待五百美元<Sample500>
。和新括号<600>
下一个< Sample>
&#34;。
在上面的句子中我想得到&#34;&lt;&#34;之间的字符串。和&#34;&gt;&#34;比如["Sample500","600"," Sample"]
为此我使用正则表达式,如 - &gt;
"I expect five hundred dollars <Sample500>. and new brackets <600> next <Sample>".match(/\<<[^>]+>\>/g)
请提供有效的正则表达式
答案 0 :(得分:2)
答案 1 :(得分:1)
这将为您解决问题:
var s = "I expect five hundred dollars <Sample500>. and new brackets <600> next <Sample>";
var matches = [];
s.replace(/<(.*?)>/g, function(g0,g1){
matches.push(g1);
});
console.log(matches);