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.
Unfortunately, activation email could not send to your email. Please try again.

How to count the occurrence of a word in Text?

Thread ID:

Created:

Updated:

Platform:

Replies:

39804 Jan 18,2006 09:49 AM Jan 18,2006 06:26 PM Windows Forms 1
loading
Tags: EditControl
feng chen
Asked On January 18, 2006 09:49 AM

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 4.1.0.10 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 06:26 PM

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.

CONFIRMATION

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.

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.

;