Articles in this section
Category / Section

How to get word count in the document using WinRT SfRichTextBoxAdv ?

1 min read

In SfRichTextBoxAdv control, you can calculate total word count in the document using the Find functionality. By matching the regular expression to specify whole words, you can find all occurrences of whole words in the document. The text search results count specifies the total word count in the document.

The following XAML code denotes how to initialize SfRichTextBoxAdv control.

XAML

<RichTextBox:SfRichTextBoxAdv x:Name="richTextBoxAdv" xmlns:RichTextBox="using:Syncfusion.UI.Xaml.RichTextBoxAdv"/>

 

The following sample code snippet demonstrates to find all occurrences of whole words in the document.

C#

// Regular expression to match whole words - (\w+)
Regex regex = new Regex("(\\w+)");
// Find all occurences of the specified Regex pattern
TextSearchResults results = richTextBoxAdv.FindAll(regex,FindOptions.None);
// Returns the word count
int wordsCount = results.Count;

VB

' Regular expression to match whole words - (\w+)
Dim regex As New Regex("(\w+)")
' Find all occurences of the specified Regex pattern
Dim results As TextSearchResults = richTextBoxAdv.FindAll(regex, FindOptions.None)
' Returns the word count
Dim wordsCount As Integer = results.Count

 

Conclusion

I hope you enjoyed learning about how to get word count in the document using WinRT SfRichTextBoxAdv.

You can refer to our WinRT SfRichTextBox page to know about its other groundbreaking feature representations , and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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