Hi Tamir,
Can not you see my reply ? I can find my reply in google, please refer to:
http://groups.google.com/groups?q="Regex+question"+"Jeffrey+Tan"&hl=
zh-CN&lr=&ie=UTF-8&oe=UTF-8&selm=6Iw73AYDEHA.1672%40cpmsftngxa06.phx.gbl&rnu
m=1
Also, I have included my original reply in this post:
"Based on my understanding, you want to use Regular Expression in .Net to
do
some string match.
For your sample, I have writen code for you. Please do like this:
private void button_Click(object sender, System.EventArgs e)
{
string
inputstring="wrtsdlfgkjsdlkfgWord1332233sdfglkjdslkfgjsldkgjWord22344sdfoisd
fkjgh";
Regex rg=new Regex(@"(Word1|Word2)(?<TEST>\d+)");
MatchCollection mc=rg.Matches(inputstring);
for(int i=1;i< mc.Count+1;i ++)
{
MessageBox.Show("The "+ i.ToString() +"th match TEST is: "
+mc[i-1].Groups["TEST"].Value);
}
}
Note: Du Dang's suggestion has a little problem, you should place
Word1|Word2 together, or Word2 will go together with "(?<TEST>\d+)"
=========================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance."
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.