Reputation: 21
"I expect five hundred dollars <Sample500>
. and new brackets <600>
next < Sample>
".
in the above sentence i want to get the strings between "<" and ">" like ["Sample500","600"," Sample"]
for that i'm using the regular expression like -->
"I expect five hundred dollars <Sample500>. and new brackets <600> next <Sample>".match(/\<<[^>]+>\>/g)
please provide valid regular expression
Upvotes: 2
Views: 1921
Reputation: 11116
this will do the trick for you:
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);
Upvotes: 3