Count number of characters in a string

Is there any way with a WEBI formula to count the number of occurances of a certain character in a string field ?

Ex- “Fig-Tree-Bush”

If I counted the number of “-” in the above string, the value would be 2.

Thanks


mountainman (BOB member since 2008-09-02)

=Length([string]) - Length(Replace([string];"-";""))

Marek Chladny :slovakia: (BOB member since 2003-11-27)

It worked !!

Thank you very much !!


mountainman (BOB member since 2008-09-02)

That’s great I sunddenly had this issue today and a search of count within string popped up this thread as second on the list and it was only asked and resolved yesterday.


Nniixx :australia: (BOB member since 2009-09-02)

Great solution. I am looking for this one. Thank you all.


VJ29 (BOB member since 2011-06-20)

:wink:


Marek Chladny :slovakia: (BOB member since 2003-11-27)

:smiley: Perfect!! I didn’t want to write a custom function for this. Sooo glad I saw this, worked perfectly! I needed to see if there was only one period in the account string (2 sections instead of the needed 3), if so add the third section as all zeroes.

Ex input data:

Account
45.6789
90.5375.111

First record needs ‘.000’ added to the end of the account string. In the query mapping the input I wrote it as follows:

ifthenelse(Length(Account) - Length(replace_substr(Account,’.’,’’)) = 1, rtrim_blanks(Account) || ‘.000’, Account)

Output:

Account
45.6789.000
90.5375.111

Thanks so much! :+1:


CCRDad (BOB member since 2014-01-27)