RegEx.Search

From Xojo Documentation
Jump to: navigation, search
Method

RegEx.Search([TargetString as String][,SearchStartPosition as Integer]) As RegExMatch

Finds SearchPattern in TargetString, beginning at SearchStartPosition.

SearchStartPosition is zero-based.

Notes

If it succeeds, it returns a RegExMatch. Both parameters are optional; if TargetString is omitted, it assumes the previous TargetString, so you will want to pass a TargetString the first time you call Search. If you call Search with a TargetString and omit SearchStartPosition, zero is assumed. If you call Search with no parameters after initially passing a TargetString, it assumes the previous TargetString and will begin the search where it left off in the previous call. This is the easiest way to find the next occurrence of SearchPattern in TargetString.

The RegExMatch will remember the ReplacementPattern specified at the time of the search.

Example

This example finds occurrences of "software" in the supplied string. Note that RegEx searches are case-insensitive by default:

Dim re As New RegEx
Dim match As RegExMatch

re.SearchPattern = "software"
match = re.Search("How much software can a Software Developer make?")

Dim result As String
Do
If match <> Nil Then
result = match.SubExpressionString(0)
MsgBox(result)
End If

match = re.Search
Loop Until match Is Nil
Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About