Reputation: 1560
I have a string of random characters between A and z, such as tahbAwgubsuregbbu
and I can easily capture between {1,n}
characters before a s
with ([A-z]{1,8})s
, but now I am trying to ignore a single (or multiple characters) before the s
is matched. For example in the string above, I want to exclude any w
characters. I understand I can't "jump" over the w
with a capture group and return tahbAgub
, but could I create two capture groups where the concatenation of those two groups is {1,n}
characters, such as 1. tahbA
2. gub
?
Upvotes: 0
Views: 51
Reputation: 10340
Try this:
/(.{0,8})?w(.{0,8})?s/
According to this comments, maybe you need to split your string. Something like this:
var str = "tftftfwtahbAwgubsuregbbu";
var res = str.split(/w|s/);
document.write(res);
Upvotes: 2