From: Tony Johansson on 20 May 2010 04:50 Hi! Here I have two simple regular expression. The first one give true which according to me is correct. The second one also give true but it should give false according to me because I say that a match should exist if you have zero o like tn as in the first example.but here I have one o. So why does it not work as expected to have 0 in min range status = Regex.IsMatch("tn", "to{0,}n"); status = Regex.IsMatch("ton", "to{0,}n"); //Tony
From: Jackie on 20 May 2010 05:08 On 5/20/2010 10:50, Tony Johansson wrote: > Hi! > > Here I have two simple regular expression. > The first one give true which according to me is correct. > The second one also give true but it should give false according to me > because > I say that a match should exist if you have zero o like tn as in the first > example.but > here I have one o. > > So why does it not work as expected to have 0 in min range > > status = Regex.IsMatch("tn", "to{0,}n"); > status = Regex.IsMatch("ton", "to{0,}n"); > > //Tony > > "o{0,}" would mean zero or more of "o". Same as "o*?" It matches because there are more than zero.
From: Peter Duniho on 20 May 2010 05:12 Tony Johansson wrote: > Hi! > > Here I have two simple regular expression. > The first one give true which according to me is correct. > The second one also give true but it should give false according to me > because > I say that a match should exist if you have zero o like tn as in the first > example.but > here I have one o. > > So why does it not work as expected to have 0 in min range > > status = Regex.IsMatch("tn", "to{0,}n"); > status = Regex.IsMatch("ton", "to{0,}n"); Try reading this: http://msdn.microsoft.com/en-us/library/az24scfc.aspx#quantifiers The quantifier "{0,}" means _at least_ zero 'o' characters. Which you have in both strings. You might want to keep that web page handy. It's chock full of useful information about regex. Pete
From: Harlan Messinger on 20 May 2010 11:07 Jackie wrote: > On 5/20/2010 10:50, Tony Johansson wrote: >> Hi! >> >> Here I have two simple regular expression. >> The first one give true which according to me is correct. >> The second one also give true but it should give false according to me >> because >> I say that a match should exist if you have zero o like tn as in the >> first >> example.but >> here I have one o. >> >> So why does it not work as expected to have 0 in min range >> >> status = Regex.IsMatch("tn", "to{0,}n"); >> status = Regex.IsMatch("ton", "to{0,}n"); >> >> //Tony >> >> > > "o{0,}" would mean zero or more of "o". Same as "o*?" Same as "o*". "o{0,}?" is the same as "o*?". > It matches because there are more than zero.
From: Jackie on 20 May 2010 11:56 On 5/20/2010 17:07, Harlan Messinger wrote: > Same as "o*". "o{0,}?" is the same as "o*?". Yes. I corrected myself already in an earlier post. :)
|
Pages: 1 Prev: Get Windows OS version as string Next: Porting ASP.NET/SQL Server to JAVA/Oracle |