String manipulation tips anyone?
What is possible through string manipulation... any tips someone could give for a person who really hasn't done much with strings (besides stick them together and assign new values to them)? Perhaps a halpful tutorial?
I need to locate a string in a rich text box, then assign it and the 32 characters that follow it to it's own string. Tips/Codes anyone?
Re: String manipulation tips anyone?
The first thing to do is take a look at the MSDN help topic for the String class and see what members it has and what each can do.
Re: String manipulation tips anyone?
Using String.IndexOf and String.Substring...
VB Code:
Dim TestString As String = "blah blah test12345678901234567890123456789012end"
Dim SearchString As String = "test"
Dim Result As Integer = TestString.IndexOf(SearchString, 0)
If Result >= 0 Then
MessageBox.Show(TestString.Substring(Result, SearchString.Length + 32))
End If
Using Regex...
VB Code:
Dim TestString As String = "blah blah test12345678901234567890123456789012end"
Dim SearchString As String = "test"
Dim RegexPattern As String = SearchString & ".{32}"
Dim MyMatches As System.Text.RegularExpressions.MatchCollection = _
System.Text.RegularExpressions.Regex.Matches(TestString, RegexPattern)
For Each Match As System.Text.RegularExpressions.Match In MyMatches
MessageBox.Show(Match.Value)
Next