javascript regexp capture match index substring

In this example I want capture the fourth hide in S is hide3;

var S="gwrtgwhide0regwtrghide1erthgrthide2rtgbwtghide3ertghtrwhide4wertgerghide5ertghwrtghide6ewrtghwrtghide7wertgqew";

var j=/^((?:((?!hide\d).)*hide\d)){3}(?:((?!hide\d).)*(hide\d))/.exec(S);

console.log(j[j.length-1]);
Code (JavaScript):

I can to make a function for this in native […]

See original post by invalid@example.com (weavercrowds)

Leave a Reply