surendra kumar
surendra kumar

Reputation: 21

Get multiple strings between two matched characters using jquery regular expression

"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

Answers (2)

aelor
aelor

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

vks
vks

Reputation: 67968

<([^>]*)>

You can try this.See demo.

http://regex101.com/r/kM7rT8/1

Upvotes: 2

Related Questions