How To Capture This Pattern With Regex In Javascript?
How to capture the following pattern using JavaScript regular expressions? I would like to capture the first sequence of characters ending at a word boundary. The sequence length s
Solution 1:
If I well understood try something like
var n = 6,
str = "aa bb cc ddd ee",
re = newRegExp("^.{"+ (n+1) +"}.*?\\b");
str.match(re); // "aa bb cc"
Solution 2:
This regex should work
"^.{" + (n+1) + ",}?\b"
Post a Comment for "How To Capture This Pattern With Regex In Javascript?"