Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

SPlit string after =

I need to get the string from a larger string

In my source string will be a "starter" string PP=  I need everything after that and before the very next comma

So...if my source string is

GR-4,DD=3,SW=N,PP=lrbrister,PE=1234

Then I just want
lrbrister

also...the PP= can appear anywhere in the string
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Using standard string manipulation functions:
        Dim data As String = "GR-4,DD=3,SW=N,PP=lrbrister,PE=1234"

        Dim startTag As String = "PP="
        Dim startIndex As Integer = data.IndexOf(startTag)
        If startIndex <> -1 Then
            Dim commaIndex As Integer = data.IndexOf(",", startIndex)
            If commaIndex <> -1 Then
                Dim value As String = data.Substring(startIndex + startTag.Length, commaIndex - (startIndex + startTag.Length))
                Debug.Print("value = " & value)
            End If
        End If

Open in new window

SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Perfect guys.

A nod to kaufmed for an alternate solution