Category / Section
How to count the number of occurrences of a string in WinForms SyntaxEditor (EditControl)?
1 min read
Count
The number of occurences of a string in Edit Control can be found using the Matches method of the Regex class.
C#
Regex r = new Regex(searchText, RegexOptions.IgnoreCase); MatchCollection ma = r.Matches(this.editControl1.Text); return ma.Count;
VB
Dim r As Regex = New Regex(pattern, RegexOptions.IgnoreCase) Dim ma As MatchCollection = r.Matches(Me.editControl1.Text) return ma.Count
Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting#regex