remove leading string

How can I remove  " or " from this string? I want to remove the leading  "or"
string " or id='1' or id=' 2' or etc
I want "id='1' or id='2'
Who is Participating?
stevepicksConnect With a Mentor Commented:
here is the version of my initial code (which was php)

Dim text1 As String = " or id='1' or id='2'"
        Dim charsToTrim As Char() = "or"
        Dim stripped As String = Trim(text1)
        stripped = stripped.Trim(charsToTrim)

hope it helps
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Dim s As String = "or id =1"
        Dim newS As String = Trim(Replace(s, "or ", ""))
$text= " or id='1' or id='2' or";
$trimmed = trim($text);
$trimmed = trim($trimmed, "or");
echo $trimmed;

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
even this gives you what you want
Dim s As String = " or id='1' or id=' 2'"
        Dim newS As String = Trim(Replace(s, "or ", ""))
VBdotnet2005Author Commented:
I want to remove only leading "or"
or id='1' or id=' 2'
to  id='1' or id=' 2'  etc
ZhaolaiConnect With a Mentor Commented:
       Dim strTemp As String = " or id='1' or id=' 2'"
        strTemp = strTemp.Trim.TrimStart(New Char() {"o", "r"}).Trim

ZhaolaiConnect With a Mentor Commented:
Even simpler:

        Dim strTemp As String = " or id='1' or id=' 2'"
        strTemp = strTemp.TrimStart(New Char() {" ", "o", "r"})

John (Yiannis) ToutountzoglouConnect With a Mentor Instructor Multiengine PilotCommented:
Or Very simple
Dim s As String
        s = "or id='1' or id=' 2'"
        Dim s1 As String = s.Remove(0, 3)
        Dim s2 As String = Trim(s1)
        Me.Label1.Text = s2

Open in new window

I just tested the accepted solution. It leaves a leading space in the resulting string.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.