[Source] GetBetween without Regex

Discussion in 'Programming General' started by Blupig, Jan 11, 2012.

[Source] GetBetween without Regex
  1. Unread #1 - Jan 11, 2012 at 10:01 AM
  2. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    [Source] GetBetween without Regex

    Recently for my C++ classes and during highschool for when I made my Java scriptable bot, I've had to make GetBetween functions to easily get between two strings from a source point. I've been using one I found online VB for quite some time, but realized that it can be done in a far more simple way:

    Code:
        Private Function GetBetween(ByVal Source As String, ByVal Start As String, ByVal Finish As String) As String
    
            Dim index As Integer = InStr(Source, Start) + (Start.Length - 1)
            Dim fIndex As Integer = InStr(Source, Finish) - 1
            Dim len As Integer = fIndex - index
    
            Return Source.Substring(index, len)
    
        End Function
    
    Gets the string between Start and Finish from the text Source.
     
  3. Unread #2 - Jan 12, 2012 at 4:03 AM
  4. matt_sells
    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    matt_sells Member

    [Source] GetBetween without Regex

    how fast is it compared with regex? will it create lag/slow program?
     
  5. Unread #3 - Jan 16, 2012 at 2:22 PM
  6. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    [Source] GetBetween without Regex

    Nope. You might experience like a couple ms of lag but it's not hard to make a function like this asynchronous.
     
< Java Homework Question | Few Computer Science Related Questions >

Users viewing this thread
1 guest


 
 
Adblock breaks this site