J
Jason Gleason
What's the most efficient way to get the number of occurences of a certain
string in another string..for instance i'm using the following code right
now...
private int CharacterCounter(String text,String Character)
{
int count = 0;
for (int i = 0; i < text.Length; i++)
{
if(text.Substring(i,1) == Character)
{
count++;
}
}
return count;
}
The problem with this way is it's not the fastest doing big strings multiple
times over the course of a program run. Is there an easier/faster way to do
it using regular expressions?
string in another string..for instance i'm using the following code right
now...
private int CharacterCounter(String text,String Character)
{
int count = 0;
for (int i = 0; i < text.Length; i++)
{
if(text.Substring(i,1) == Character)
{
count++;
}
}
return count;
}
The problem with this way is it's not the fastest doing big strings multiple
times over the course of a program run. Is there an easier/faster way to do
it using regular expressions?