web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Word count for textbox
Power Apps
Unanswered

Word count for textbox

(1) ShareShare
ReportReport
Posted on by 249

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

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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.

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    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, " "))

     

    timl_0-1614877122393.png

     

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @techtudoor 

    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.

     

  • techtudoor Profile Picture
    249 on at

    @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

  • techtudoor Profile Picture
    249 on at

    @timl 

     

    Thank you, I will keep this in mind if I need to do this for a single line of text input. 

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @techtudoor 

    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.

     

  • techtudoor Profile Picture
    249 on at

    Thanks Randy. That explanation was great. It now makes sense. Greatly appreciate you taking time to explain this. 

  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    Can you please tell me a solution to get the number of letters instead of words?

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    @ShaheerAhmad 

    The Len function returns the number of letters/characters.

    Len(TextInput1.Text)

     

  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    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.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard