UtilRegExGetMatchesPositions(Regex, String, Int32) Method
Gets a friendlly collection of all the RegEx matches being at the specified group index, 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,
int groupIndex
)
Public Shared Function GetMatchesPositions (
regEx As Regex,
text As String,
groupIndex As Integer
) As IEnumerable(Of MatchPositionInfo)
Dim regEx As Regex
Dim text As String
Dim groupIndex As Integer
Dim returnValue As IEnumerable(Of MatchPositionInfo)
returnValue = UtilRegEx.GetMatchesPositions(regEx,
text, groupIndex)
public:
static IEnumerable<MatchPositionInfo>^ GetMatchesPositions(
Regex^ regEx,
String^ text,
int groupIndex
)
static member GetMatchesPositions :
regEx : Regex *
text : string *
groupIndex : int -> 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 RegEx.
- groupIndex Int32
-
The group index of the successful 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, groupIndex:=0)
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.