Reputation: 13
I'm using this regex:
/<([^>]*)>/g
for calculating the number of characters between <
and >
symbols using JavaScript, but I also need to count the number of characters added after a <
but before closing the successive >
when a user is typing.
For example:
<I need to count this> this not <this yes> and <also this
Upvotes: 0
Views: 60
Reputation: 10230
Not purely a regex solution but you could do the following , this solution uses the forEach loop and also the match method.
var newArr = [];
str.match(/<([^>]+)/g).forEach( (e , i) => newArr.push( e.slice(1) ) ); // ["I need to count this", "this yes", "also this"]
Upvotes: 0
Reputation: 825
You could use <([^>]*).
>
occuring after a <
.Upvotes: 1