• Log in or sign up for an account here: https://www.sythe.org/login

[Source] GetBetween without Regex

Blupig

BEEF TOILET
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
[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.
 
[Source] GetBetween without Regex
how fast is it compared with regex? will it create lag/slow program?

Nope. You might experience like a couple ms of lag but it's not hard to make a function like this asynchronous.
 
Runescape Gamblingrunescape gambling
Back
Top