Hello I don't understand regex fully but I found a great javascript function that does exactly what I need, How would I convert this properly to vb.net? I've tried a few things but could not get the same exact regex string to work when doing it the vb.net way...any thoughts? Any help would be appreciated.
Code:function maxRepeat(input) {
var reg = /(?=((.+)(?:.*?\2)+))/g;
var sub = "";
var maxstr = "";
reg.lastIndex = 0;
sub = reg.exec(input);
while (!(sub == null)) {
if ((!(sub == null)) && (sub[2].length > maxstr.length)) {
maxstr = sub[2];
}
sub = reg.exec(input);
reg.lastIndex++;
}
return maxstr;
}
This functions returns the largest sequence of characters that appear at least twice. "one two one three one four" would return "one t" <--with space || "onetwoonethreeonefour" would return "onet"
"324234241122332211345435311223322112342345541122332211234234324" returns "1122332211234234"
So far no luck with getting the same results as with javascript even with tweaking the regex string around a bit.. there must be something I don't understand.
What is the vb.net regex engine equivalent of "/(?=((.+)(?:.*?\2)+))/g"?Code:Dim regex As Regex = New Regex("/(?=((.+)(?:.*?\2)+))/g")
Dim match = regex.Matches("one two three one four",0)
MsgBox(match.count) <---find anything?

