Class
RegExOptions
Description
Used to specify options when doing a search using regular expressions.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Property descriptions
RegExOptions.CaseSensitive
CaseSensitive As Boolean
Specifies if case is to be considered when matching a string. The default is False.
RegExOptions.DotMatchAll
DotMatchAll As Boolean
Normally the period matches everything except a new line, this option allows it to match new lines. The default is False.
RegExOptions.Greedy
Greedy As Boolean
Greedy means the search finds everything from the beginning of the first delimiter to end of the last delimiter and everything in-between.
For example, say you want to match the following bold-tagged text in HTML:
The <b>quick</b> brown <b>fox</b> jumped
If you use this pattern:
<b>.+</b>
You end up matching <b>quick</b> brown <b>fox</b>
which isn't what you wanted.
So, you can turn Greedy off or use this syntax:
<b>.+?</b>
and you will match <b>quick</b>
, which is exactly what you wanted.
The default is True.
RegExOptions.LineEndType
LineEndType As Integer
Changes the way n is expanded for ReplacementPatterns. It is in effect for the current Regular Expression "session."
This property has no effect on SearchPatterns if TreatTargetAsOneLine is True.
LineEndType can take on the following values:
Value |
Description |
---|---|
0 |
Any line ending (Windows, Macintosh, or Unix). This is the default. |
1 |
The default for the current platform. If running on Macintosh, the same as 2; if running on Windows, the same as 3, if running on Linux, the same as 4. |
2 |
Mac ASCII 13 or r |
3 |
Win32 ASCII 10 or n |
4 |
Unix ASCII 10 or n |
RegExOptions.MatchEmpty
MatchEmpty As Boolean
Indicates whether patterns are allowed to match the empty string. The default is True.
RegExOptions.ReplaceAllMatches
ReplaceAllMatches As Boolean
Indicates whether all occurrences of the pattern are to be replaced. The default is False.
RegExOptions.StringBeginIsLineBegin
StringBeginIsLineBegin As Boolean
Indicates whether a string's beginning should be counted as the beginning of a line. The default is True.
RegExOptions.StringEndIsLineEnd
StringEndIsLineEnd As Boolean
Indicates whether a string's end should be counted as the end of a line. The default is True.
RegExOptions.TreatTargetAsOneLine
TreatTargetAsOneLine As Boolean
Ignores internal newlines for purposes of matching against '^' and '$'. The default is False.
Sample code
Normally, RegEx searches are case insensitive. This example does a case-sensitive search using by supplying the a RegExOptions instance with CaseSensitive = True:
Var re As New RegEx
Var match As RegExMatch
Var ro As New RegExOptions
ro.CaseSensitive = True
re.Options = ro
re.SearchPattern = "software"
match = re.Search("How much software can a Software Developer make?")
Var result As String
Do
If match <> Nil Then
result = match.SubExpressionString(0)
MessageBox(result)
End If
match = re.Search
Loop Until match Is Nil
Compatibility
Desktop, console, web and iOS project types on all supported operating systems.
See also
Object parent class; RegEx, RegExMatch classes.