UtilRegExGetMatchesPositions(Regex, String) Method
Gets a friendlly collection of all the RegEx matches being at group index Zero, and their matches positions.
Namespace: DevCase.Core.DataProcessing.RegExAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static IEnumerable<MatchPositionInfo> GetMatchesPositions(
Regex regEx,
string text
)
Public Shared Function GetMatchesPositions (
regEx As Regex,
text As String
) As IEnumerable(Of MatchPositionInfo)
Dim regEx As Regex
Dim text As String
Dim returnValue As IEnumerable(Of MatchPositionInfo)
returnValue = UtilRegEx.GetMatchesPositions(regEx,
text)
public:
static IEnumerable<MatchPositionInfo>^ GetMatchesPositions(
Regex^ regEx,
String^ text
)
static member GetMatchesPositions :
regEx : Regex *
text : string -> IEnumerable<MatchPositionInfo>
No code example is currently available or this language may not be supported.
- regEx Regex
-
The RegEx pattern.
- text String
-
The text where to test the matches.
IEnumerableMatchPositionInfo
An
IEnumerableT that contains the RegEx matches and their positions.
This is a code example.
No code example is currently available or this language may not be supported.
Sub Test()
Dim regExpr As New Regex("Dog(s)?", RegexOptions.IgnoreCase)
Dim text As String = "One Dog!, Two Dogs!, three Dogs!"
RichTextBox1.Text = text
Dim matchesPos As IEnumerable(Of MatchPositionInfo) = GetMatchesPositions(regExpr, text)
For Each matchPos As MatchPositionInfo In matchesPos
Console.WriteLine(text.Substring(matchPos.StartIndex, matchPos.Length))
With RichTextBox1
.SelectionStart = matchPos.StartIndex
.SelectionLength = matchPos.Length
.SelectionBackColor = Color.IndianRed
.SelectionColor = Color.WhiteSmoke
.SelectionFont = New Font(RichTextBox1.Font.Name, RichTextBox1.Font.SizeInPoints, FontStyle.Bold)
End With
Next matchPos
With RichTextBox1
.SelectionStart = 0
.SelectionLength = 0
End With
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.