Hello,
I have a unique problem that i'm hoping someone can help me with. I have a
database that has the following data in a field:
5564564000005450015845456456454540015845456456499900158

If you look closely the string "00158" is listed 3 times. This is just an
example, it could be listed either one time or a hundred times in this one
field. I need to write some code that loops through each instance of the
string and counts the number of times the value "00158" appears.

I'm at a loss. Does anyone have any thoughts? Thanks.

Richard M.

Re: Count string by Tim

Tim
Wed Oct 19 10:24:21 CDT 2005

Two ways come to mind. You should be able to use the IndexOf method of the
string class to loop through the string and count the number of times that
the substring is found. The other way is to use regular expressions to find
any matches and then examine the match count.

IndexOf
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemstringclassindexoftopic4.asp

Regex
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextregularexpressionsregexclasstopic.asp

--
Tim Wilson
.NET Compact Framework MVP

"Richard M" <RichardM@discussions.microsoft.com> wrote in message
news:C971B167-07D9-49D2-BA60-895ED73271BF@microsoft.com...
> Hello,
> I have a unique problem that i'm hoping someone can help me with. I have a
> database that has the following data in a field:
> 5564564000005450015845456456454540015845456456499900158
>
> If you look closely the string "00158" is listed 3 times. This is just an
> example, it could be listed either one time or a hundred times in this one
> field. I need to write some code that loops through each instance of the
> string and counts the number of times the value "00158" appears.
>
> I'm at a loss. Does anyone have any thoughts? Thanks.
>
> Richard M.
>