Reputation: 3685
I have a string like this:
Executed 29 of 31 (3 FAILED) (skipped 2) (0.283 secs / 0.08 secs)
I want to get the value after skipped
. But if I give the regex as:
/skipped/
it only matches the skipped
character, but I want to get the number 2
after that.
How to do this in javascript?
Upvotes: 1
Views: 47
Reputation: 67968
skipped\s+(\d+)
Try this.Grab the capture or group.
See demo.
https://www.regex101.com/r/rG7gX4/9
var re = /skipped\s+(\d+)/gmi;
var str = 'Executed 29 of 31 (3 FAILED) (skipped 2) (0.283 secs / 0.08 secs)';
var m;
while ((m = re.exec(str)) != null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
// View your result using the m-variable.
// eg m[0] etc.
}
Upvotes: 3