Articles in this section
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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied