Solved

remove leading string

Posted on 2010-08-12
9
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Technology Partners: 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!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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