How to get word count in the document using WinRT SfRichTextBoxAdv ?
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.
<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.
// 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;
' 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
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.
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!