Count the number of times a string occurs

Hi!

If I have a list or a text containing:

“Chair; Chair; Table; Chair; Window; Table”

how can I get the number of times that the different words occur? I.e. that “Chair” occurs 3 times, “Table” occurs 2 times and “Window” occur 1 time?

Thanks in advance =)

Regards

Frank

Subject: Count the number of times a string occurs

There is An intelligent matahematical way .

Suppose you have a list

“Chair”:“Chair”:“Table”:“Chair”:“Window”:“Table”

Yuo need to find number of Chair in it.

first you count n1 i.e number of elements in the list

You create a string with value like this

“Chair:Chair:Table:Chair:Window:Table”

now use @replacesubtring function on the string

like

@replacesubstring(“Chair:Chair:Table:Chair:Window:Table”

;“Chair:”;“Chair”)

this will modify the string to

“ChairChairTable:ChairWindow:Table”

now apply explode to the string like

@explode(“ChairChairTable:ChairWindow:Table”

;“:”)

it will result in a list like

“ChairChairTable”:“ChairWindow”:“Table”

now again count bumber of elememts in the list i.e n2

aplly n1-n2 =number of chairs

hope you understand the concept

Subject: RE: Count the number of times a string occurs

Thanks a lot! Took me a while to understand how it worked but it’s a piece of genius code! =)

Regards

Frank