How to skip character in capture group in JavaScript Regexp?

JavascriptWeb DevelopmentFront End Technology

You cannot skip a character in a capture group. A match is always consecutive, even when it contains things like zero-width assertions.


However, you can access the matched groups in a regular expression like the following code −

         var str = "Username akdg_amit";
         var myReg = /(?:^|\s)akdg_(.*?)(?:\s|$)/g;
         var res = myReg.exec(str);
Published on 23-Feb-2018 07:02:02