panuvin
10-13-2006, 05:42 PM
Hello all,
I'm trying to figure out a way to go through a string and count the number of times a certain string occurs. I'm not sure if there's a built-in function to do this, but I wrote the following non-working function to do so. Can anyone tell me what's wrong with it or how I can accurately get a count of substrings?
string temp = htmlSource;
int chargeCt = 0;
while (temp.Contains("Charge Number") == true)
{
temp.Replace("Charge Number", "Charge #");
chargeCt++;
}
Thanks in advance!
Panuvin
I'm trying to figure out a way to go through a string and count the number of times a certain string occurs. I'm not sure if there's a built-in function to do this, but I wrote the following non-working function to do so. Can anyone tell me what's wrong with it or how I can accurately get a count of substrings?
string temp = htmlSource;
int chargeCt = 0;
while (temp.Contains("Charge Number") == true)
{
temp.Replace("Charge Number", "Charge #");
chargeCt++;
}
Thanks in advance!
Panuvin