Notifications
Announcements
So I am building an App that has a multi-line textbox that needs to have a limit of x amount of words. I can count characters, but not sure how to do a word count to show the user the amount of words they have typed or have left.
Any suggestions greatly appreciated
@techtudoor
Consider the following formula:
CountRows(Filter(MatchAll(yourTextInputControl.Text, "\S*(\s|\n?)"), !IsBlank(FullMatch)))
This will tell you how many words you have.
I hope this is helpful for you.
Hi @techtudoor
I'd suggest pretty much the same as Randy. I usually just split the text by the space character and do a count of the result.
CountRows(Split(TextInput2.Text, " "))
Yep, @timl 's solution will work too, but you might have issue with that for a mult-line text as words in those that are at the end of a line are typically ended with a char(10). The match function expression will account for that.
@RandyHayes
That worked great, Thank you so much. Now to show my ignorance. Could you explain what "\S*(\s|\n?)" is doing? This way I can understand what I am doing rather than just typing it in.
Thank you
@timl
Thank you, I will keep this in mind if I need to do this for a single line of text input.
This is a regular expression. It essentially says - match any thing that is not a white space (\S) and ends with either zero or more (?) a whitespace (/s) or zero or more (?) a newline (\n)
So this text:
The quick brown fox
Is :
\S\S\S\s\S\S\S\S\S\n\S\S\S\S\S\s\S\S\S\s T h e q u i c k b r o w n f o x
The regular expression "\S*(\s|\n?)" says to match all of the \S's that end with \s or \n
The MatchAll function returns a table. The table has records with two columns, the FullMatch and the character location. We only care about the number of full matches and we first filter that to make sure we have no blank full matches, then count the number of rows.
Thanks Randy. That explanation was great. It now makes sense. Greatly appreciate you taking time to explain this.
Can you please tell me a solution to get the number of letters instead of words?
@ShaheerAhmad
The Len function returns the number of letters/characters.
Len(TextInput1.Text)
Thanks a lot brother
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 796 Most Valuable Professional
Michael E. Gernaey 327 Super User 2025 Season 2
Power Platform 1919 268