Yes, there is a way and is very easy, the steps are the next:
e.g.
Original String = ‘Hello World’, lets suppose I am looking how many ‘o’s that string has
Char = ‘o’
String without chars = ‘Hell Wrld’
Original length – New string length = 11 – 9 = 2 ← This is the count of chars ‘o’ in ‘Hello World’
I will add some pictures of a microflow in case it is helpful
IMPORTANT NOTE: This example is case sensitive, if you want it to be case insensitive convert your string and char first to uppercase or lowercase using functions toLowerCase or toUpperCase, whatever you prefer.
Hope it helps
Hi Steffi
I have found this Java Action that you could use to count the occurence of a character in a string:
public class CountOccurences
{
public static void main(String args[])
{
String input = "aaaabbccAAdd";
char search = 'a'; // Character to search is 'a'.
int count=0;
for(int i=0; i<input.length(); i++)
{
if(input.charAt(i) == search)
count++;
}
System.out.println(count);
}
}
Instead of System.out.println you could use “return count;” to use the given amount in a microflow