Repeated words in a string.

by Soll

Back to Mechanic's Corner.

Soll2006-10-28 16:04:15
For zMUD: I'm curious as to if it's possible to count how many times a certain string is repeated inside the variable. For example, if I have:

one|one|one|two|four|one|seven|nine

and I wanted to have it count how many times the word 'one' turned up, how would I? Is it possible?
Unknown2006-10-28 16:12:07
The %countlist function will do exactly what you want. It counts the times things appear in a string list and returns a data record variable.

CODE
#SHOW %db(%countlist(@listvar), "one")
Soll2006-10-28 17:20:11
Thank you very much, Zarquan. smile.gif