How to count the number of characters repeated in a string?

Hi Everyone,

How we can achieve, to count the number of characters in a given string?

For example

InputStrng=“Welcome to UiPath”

Output:
w 1
e 2
o 2

Can anyone please guide me to achieve this.

Thank you very much in advance.

Regards
Vishnu

Hi @winningvish

I think you can use below code to do this

var reg = new RegExp(char,"U");
string.match(reg).length;

Or you can do this as well

int varCount Regex.Matches(varString, "e", RegexOptions.Multiline Or RegexOptions.IgnoreCase).Count

Thanks,
Prankur

Hello @winningvish
use below in log message
String.join(",",(from chr in strString.toList.distinct select x = chr.tostring & "-" & (from chr2 in strString.ToList where chr2 = chr).Count ))