• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

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'
0
VBdotnet2005
Asked:
VBdotnet2005
  • 3
  • 3
  • 2
  • +1
4 Solutions
 
John (Yiannis) ToutountzoglouCommented:
Dim s As String = "or id =1"
        Dim newS As String = Trim(Replace(s, "or ", ""))
0
 
stevepicksCommented:
<?
$text= " or id='1' or id='2' or";
$trimmed = trim($text);
$trimmed = trim($trimmed, "or");
echo $trimmed;

?>
0
 
John (Yiannis) ToutountzoglouCommented:
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 ", ""))
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
VBdotnet2005Author Commented:
I want to remove only leading "or"
or id='1' or id=' 2'
to  id='1' or id=' 2'  etc
0
 
stevepicksCommented:
Sorry
here is the vb.net 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
Cheers
0
 
ZhaolaiCommented:
       Dim strTemp As String = " or id='1' or id=' 2'"
        strTemp = strTemp.Trim.TrimStart(New Char() {"o", "r"}).Trim


0
 
ZhaolaiCommented:
Even simpler:

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


0
 
John (Yiannis) ToutountzoglouCommented:
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

0
 
ZhaolaiCommented:
Interesting...
I just tested the accepted solution. It leaves a leading space in the resulting string.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now