cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
psundar6
Level III

Count number of occurrences of a character in a string

Hi,

I am trying to count the number of occurrences of a character in a string. How do I achieve that using JSL?

For eg:

Number of occurrences of letter 'A' in the below strings

APPLE -> 1

PEARS -> 1

BANANA -> 2

 

1 REPLY 1
psundar6
Level III

Re: Count number of occurrences of a character in a string

Below formula actually works perfect.

 

Length( :Name( "Col1" ) ) - Length( Substitute( :Name( "Col1" ), "A", "" ) )