Home > OS >  Why does ?: in regular expressions not work?
Why does ?: in regular expressions not work?

Time:09-26

I want to get a word with a space in the beginning but without a space in the output using ?:

issue

CodePudding user response:

Instead of the non-capturing group (?:), you can use the "match prefix but exclude" group (?<=).

let g = /(?<=\s)j\w /i;
console.log("Here is John".match(g));
  • Related