//The following logic useful for C# also
int characterpos = -1;
for ( int i = 0; i < 10; i++ )
{
characterpos = s.indexOf( 'searchcharacter', characterpos + 1 );
}
int characterpos = -1;
for ( int i = 0; i < 10; i++ )
{
characterpos = s.indexOf( 'searchcharacter', characterpos + 1 );
}