Let me explain. I have a string bigstring = 1234abcd4. Now i want to get all the substrings starting with 1 and ending with 4 in the bigstring.
So i wrote this code.
|
But i'm always getting 1234abcd4 and i want 1234 which is the first instance that matches. How can we do that?
Any ideas?
Thank you.
NLV RaghavendraPosted Jan 1, 2010, 11:02 AM
The string i used is an example. It isn't the exact pattern of the string. The string i get is a http response (html) of a page.
I'll get substrings based on html tags. Any ideas?
Thank you.
Kirtan PatelPosted Dec 31, 2009, 1:26 PM
Here is Correct RegEx I have made for your data that will look for all
starting with 1 and ending with 4 strings in bigString
Regex rex = new Regex("1[0-9]*4");
//Get First match
MatchCollection mc = rex.Matches(BigString);
//Get First Instance of Match
string Result = mc[0].Value.ToString();
if my answer helps you then check "Do you like this answer" check box please :)
NLV RaghavendraPosted Dec 31, 2009, 11:07 AM