string variable(FINDING ONLY ALPHABETS POSITION)

how to find a character index that starts with alphabets ...(not numbers)

for example

i have a string 1231:qwesasd',

string s=' 1231:qwesasd'

i need to get the index of character q...

can any one help me...

[258 byte] By [raj416] at [2008-1-3]
# 1

Humm... try this:

Code Snippet

int GetIndexOfLetter(string word)

{

for (int i = 0; i < word.Length; i++)

if (Char.IsLetter(word[i]))

return i;

// this word don't have letters...

return -1;

}

Regards.

vtortola at 2007-9-25 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
awesome my dear friend... thanks a lot... it works gr8.....
raj416 at 2007-9-25 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
but

Char. isSymbol is not working properly..

can you tell me why is it so....

raj416 at 2007-9-25 > top of Msdn Tech,Visual C#,Visual C# General...
# 4

Put a example where IsSymbol don't work.

Regards.

vtortola at 2007-9-25 > top of Msdn Tech,Visual C#,Visual C# General...
# 5
Try following example :

String s = "123:qawqewtey-$";

Regex r = new Regex("[a-zA-Z]");
MessageBox.Show(r.Match(s).Index.ToString());

Regex r2 = new Regex("[@#$%]");
MessageBox.Show(r2.Match(s).Index.ToString());

put any symbol you want to look for between [] in Regex's constructor. This should work for you.

decyclone at 2007-9-25 > top of Msdn Tech,Visual C#,Visual C# General...