Question[Help]parse a word

Posts 1–2 of 2 · Page 1 of 1
[Help]parse a word
How do i call it.

For example the line is: MPGH is the best site eva.
How do i parse the line if i wanted only the word "best".

Code:
Function Parse(ByVal Data As String, ByVal Left As String, ByVal Right As String) As String
        If Data.Contains(Left) AndAlso Data.Contains(Right) Then
            Return Data.Substring(Data.IndexOf(Left) + Left.Length, Data.IndexOf(Right) - Data.IndexOf(Left) - Left.Length)
        Else
            Return String.Empty
        End If
    End Function


My String Manipulation Tutorial
http://www.mpgh.net/forum/33-visual-...ipulation.html

[php]
Dim s As String = "This is the string sample"
S = S.Substring(19)
[/php]

That will grab the the 5th word (which is 19 characters in)

[php]
label1.text = s
[/php]

Now label1.text says "Sample"

Hope that helps, string manipulation is rather easy, and very effective.

Read the tut, it does through indexing for specific words, etc.

If you know the word you are trying to parse, you can use .

[php]
Dim currentSentence As String = "Sample Test"
Dim splitSentence() As String = currentSentence.Split(" "c)
For Each s As String In splitSentence
If s.Contains("test") Then MsgBox("Found Test")
Next
[/php]



Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?