We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to count the occurrence of a word in Text?

Thread ID:





39804 Jan 18,2006 02:49 PM UTC Jan 18,2006 11:26 PM UTC WinForms 1
Tags: EditControl
feng chen
Asked On January 18, 2006 02:49 PM UTC

Hi, there. How to count the occurrence of a word in Text? I read a old post about this issue, but the suggested solution is not applicable anymore since Find method is removed from release which is what I am using. FindText(...) returns a boolean value, but FindNext() retuns nothing. Another similar question is how to find out how many words are replaced when ReplaceAll() is called? This method returns nothing. Thanks. Feng Chen feng.chen@hrblock.com

Administrator [Syncfusion]
Replied On January 18, 2006 11:26 PM UTC

Hi Feng, You could find the number of occurences of any string in the EditControl using the following code : Regex r = new Regex(searchText, RegexOptions.IgnoreCase); MatchCollection ma = r.Matches(this.editControl1.Text); return ma.Count; I have attached a test sample here that illustrates the same. Please refer to it and let me know if this meets your requirements. We have also considered adding a GetInstanceCount method to the EditControl that returns the number of occurences of the specified string. We will try our very best to implement this feature request and you could track the progress of the same at this link below : Feature Request #694 - Support for GetInstanceCount method in the EditControl Thanks for your interest in Essential Edit. Regards, Guru Patwal Syncfusion, Inc.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon