Results 1 to 25 of 25

Thread: [RESOLVED] Regex Help

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    18

    Resolved [RESOLVED] Regex Help

    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.
    Code:
    Dim regex As Regex = New Regex("/(?=((.+)(?:.*?\2)+))/g")
            Dim match  = regex.Matches("one two three one four",0)
                MsgBox(match.count)   <---find anything?
    What is the vb.net regex engine equivalent of "/(?=((.+)(?:.*?\2)+))/g"?
    Last edited by paulmak10; Apr 8th, 2015 at 04:46 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width