Solved

remove leading string

Posted on 2010-08-12
9
214 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
Comment Utility
Dim s As String = "or id =1"
        Dim newS As String = Trim(Replace(s, "or ", ""))
0
 
LVL 4

Expert Comment

by:stevepicks
Comment Utility
<?
$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
Comment Utility
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
 

Author Comment

by:VBdotnet2005
Comment Utility
I want to remove only leading "or"
or id='1' or id=' 2'
to  id='1' or id=' 2'  etc
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 4

Accepted Solution

by:
stevepicks earned 32 total points
Comment Utility
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
Comment Utility
       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
Comment Utility
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
Comment Utility
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
Comment Utility
Interesting...
I just tested the accepted solution. It leaves a leading space in the resulting string.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now