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.
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 Raghavendra11 reputationPosted Dec 31, 2009, 6:07 AM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 31, 2009, 8:26 AM EST
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 Raghavendra11 reputationPosted Jan 1, 2010, 6:02 AM EST
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.