cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

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

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.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

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

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

 

 

View solution in original post

Highlighted
Community Support
Community Support

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

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

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

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

 

 

View solution in original post

Highlighted
Community Support
Community Support

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

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Anonymous
Not applicable

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

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

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,095)