VSFlexString Control > VSFlexString Properties, Events, and Methods > VSFlexString Properties > MatchString Property |
Returns or sets the string corresponding to the current match.
[form!]VSFlexString.MatchString([ MatchIndex As Long ])[ = value As String ]
Looking for a pattern in a string may result in several matches. You can retrieve information about each match using the MatchLength, MatchStart, and MatchString properties.
The optional parameter MatchIndex should be a number between zero and MatchCount - 1. The default value is the current value of the MatchIndex property.
If you assign a new value to MatchString, the original text -- stored in the Text property -- is modified and a new match is attempted automatically.
For example:
fs.Text = "The quick brown fox jumped over the lazy dog."
fs.Pattern = "[A-Z]*[a-z]+"
For i = 0 To fs.MatchCount - 1
s = fs.MatchString(i)
fs.MatchString(i) = UCase(Left(s, 1)) & Mid(s, 2)
Next
Debug.Print fs.Text
This code capitalizes the first letter of each word, producing the following output:
The Quick Brown Fox Jumped Over The Lazy Dog.
String