Hi Abrar,
Unfortunately, there is not an out-of-the-box functionality for this. you can try length(replaceAll($myString, ‘[^{myLetter}]’, ‘’)). Using your example it would look like length(replaceAll(‘Apple’, ‘[^pP]’, ‘’))
find the character index in java code at broswer then implement in java action