Hi. Does anyone know how to get number of occurencies of specific element in IEnumerable?
I have the string below and have to find out what is number of occurencies of string “CRAFORD MARK” OIB: Matični broj: 11654684 Broj osobne: 11654684 Identifikacijski broj: Id klijenta: 55 Naziv: BROKER BROKER Adresa: KK 81000 PODGORICA
OIB: Matični broj: 2409980263005 Broj osobne: 765543533 Identifikacijski broj: Id klijenta: 400110 Naziv: BULL AND BEAR Adresa: ULICA 81000 PODGORICA
OIB: Matični broj: 02708256 Broj osobne: - Identifikacijski broj: Id klijenta: 555555 Naziv: BULL AND BEAR AD Adresa: MARKA MILJANOVA 46/14 81000 PODGORICA
OIB: Matični broj: 02708256 Broj osobne: - Identifikacijski broj: Id klijenta: 39943 Naziv: CDA Adresa: X 81000 PODGORICA
OIB: Matični broj: 02320924 Broj osobne: - Identifikacijski broj: Id klijenta: 177088978 Naziv: CRAFORD MARK Adresa: HAVELA 7
OIB: Matični broj: 72138 Broj osobne: Identifikacijski broj: Id klijenta: 8771 Naziv: CRAFORD MARK Adresa: STALONE 5
OIB: Matični broj: 11778877 Broj osobne: Identifikacijski broj: Id klijenta: 15282 Naziv: CRNOGORSKI TELEKOM AD PODGORICA Adresa: STUDENTSKA BB 81000 PODGORICA
OIB: Matični broj: 2502985210023 Broj osobne: Identifikacijski broj: Id klijenta: 2806991217977 Naziv: DABAR DABAR PROBNI Adresa: MOSKOVSKA 5 81000 PODGORICA
but, as my input string nizKlijenata, is IEnumerable it doesn’t work.
When I print out nizKlijenata.ToString I get this result System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]. How can I reach whole string of this IEnumerable format?
where you looking for any text between Naziv and Adresa with the matches activity
We do understand that afterwards the occurence of CRAFORD MARK is to count
item.ToString + System.text.regularexpressions.regex.matches(item.tostring,nizKlijenata(klijentBr).ToString).count.ToString (it goes through if loop, so I have to use klijentBr to iterate through it) I get 1 even though, for example, “CRAFORD MARK” has 2 occurencies…
But I have to get count of all clients individually. For example, for “CRAFORD MARK” I have to get result 2, for client " BROKER BROKER" result would be 1, etc.
nizKlijenata.count.tostring will return count of all clients, won’t it?