Solved

remove leading string

Posted on 2010-08-12
9
217 Views
Last Modified: 2012-05-10
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
Comment
Question by:VBdotnet2005
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33422387
Dim s As String = "or id =1"
        Dim newS As String = Trim(Replace(s, "or ", ""))
0
 
LVL 4

Expert Comment

by:stevepicks
ID: 33422411
<?
$text= " or id='1' or id='2' or";
$trimmed = trim($text);
$trimmed = trim($trimmed, "or");
echo $trimmed;

?>
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33422431
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:VBdotnet2005
ID: 33422715
I want to remove only leading "or"
or id='1' or id=' 2'
to  id='1' or id=' 2'  etc
0
 
LVL 4

Accepted Solution

by:
stevepicks earned 32 total points
ID: 33422731
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
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 62 total points
ID: 33422750
       Dim strTemp As String = " or id='1' or id=' 2'"
        strTemp = strTemp.Trim.TrimStart(New Char() {"o", "r"}).Trim


0
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 62 total points
ID: 33422845
Even simpler:

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


0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 31 total points
ID: 33423296
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
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33435167
Interesting...
I just tested the accepted solution. It leaves a leading space in the resulting string.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question