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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Return total number of...
Power Apps
Answered

Return total number of a given character/string from another string

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

I cannot find a way to do this, and it seems so simple!

 

Eg, find number of 's' in 'snakes' or '.' in "www.hotmail.com"

 

Apologies if this has been asked elsewhere, but I can't find anything after lengthy searching.

 

Thanks.

Categories:
I have the same question (0)
  • Verified answer
    timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @Anonymous 

    You can call the MatchAll function to search for a character in string. MatchAll returns a table for all matches that are found. The CountRows function will then provide a count of results like so:

    CountRows(MatchAll("snakes", "s"))

    Note that the MatchAll function accepts a search pattern in the form of a regular expression. The period symbol is a special character so in your hotmail example, you would need to escape this with a \ symbol.

    CountRows(MatchAll("www.hotmail.com", "\."))

     

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Do you want to calculate the total number of a given character/string within another string?

     

    Based on the needs that you mentioned, I think the MatchAll function could achieve your needs. I have made a test on my side, please take a try with the following workaround:

    Add a Label in your app, set the Text property to following:

    CountRows(MatchAll("snakes", "s", MatchOptions.Contains))
    CountRows(MatchAll("www.hotmail.com", "\.", MatchOptions.Contains))

    Please consider take a try with above solution, check if the issue is solved.

     

    More details about the MatchAll function, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    <quote>

    Hi @MaxDonen 

    You can call the MatchAll function to search for a character in string. MatchAll returns a table for all matches that are found. The CountRows function will then provide a count of results like so:

    CountRows(MatchAll("snakes", "s"))

    Note that the MatchAll function accepts a search pattern in the form of a regular expression. The period symbol is a special character so in your hotmail example, you would need to escape this with a \ symbol.

    CountRows(MatchAll("www.hotmail.com", "\."))

     

    </quote>

    Brilliant-exactly what I was looking for. Thank you.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard