From: Tony Johansson on 20 May 2010 05:48 Hi! Here I say minimum 1 o and maximum three o but here I have more then three o and this expression give true but it should give false according to me ? bool status = Regex.IsMatch("foooooood", "o{1,3}"); //Tony
From: Willem van Rumpt on 20 May 2010 05:59 Tony Johansson wrote: > Hi! > > Here I say minimum 1 o and maximum three o but here I have more then three o > and this expression give true but > it should give false according to me ? > > bool status = Regex.IsMatch("foooooood", "o{1,3}"); > > //Tony > > Because your criteria has multiple matches: f[ooo][ooo][o]d -- Willem van Rumpt
From: Tony Johansson on 20 May 2010 06:16 "Willem van Rumpt" <nothing(a)nowhere.com> skrev i meddelandet news:e$Bg2MA%23KHA.5464(a)TK2MSFTNGP05.phx.gbl... > Tony Johansson wrote: >> Hi! >> >> Here I say minimum 1 o and maximum three o but here I have more then >> three o and this expression give true but >> it should give false according to me ? >> >> bool status = Regex.IsMatch("foooooood", "o{1,3}"); >> >> //Tony > > Because your criteria has multiple matches: > > f[ooo][ooo][o]d > > > -- > Willem van Rumpt But according to me means "o{1,3}" that I must have at least 1 o and maximum of three o. I meam what is the purpose of using a max of 3 here then ? //Tony
From: Adhal on 20 May 2010 06:25 On 20/05/2010 11:16, Tony Johansson wrote: > "Willem van Rumpt"<nothing(a)nowhere.com> skrev i meddelandet > news:e$Bg2MA%23KHA.5464(a)TK2MSFTNGP05.phx.gbl... >> Tony Johansson wrote: >>> Hi! >>> >>> Here I say minimum 1 o and maximum three o but here I have more then >>> three o and this expression give true but >>> it should give false according to me ? >>> >>> bool status = Regex.IsMatch("foooooood", "o{1,3}"); >>> >>> //Tony >> >> Because your criteria has multiple matches: >> >> f[ooo][ooo][o]d >> >> >> -- >> Willem van Rumpt > > But according to me means "o{1,3}" that I must have at least 1 o and maximum > of three o. > I meam what is the purpose of using a max of 3 here then ? > > //Tony > > Hi Tony. You have to specify that the previous/next letter can't be an "o". I am not an expert on regex but this should work [^o]o{1,3}[^o]
From: Tony Johansson on 20 May 2010 06:33 "Adhal" <user(a)example.net> skrev i meddelandet news:eW50RbA%23KHA.1888(a)TK2MSFTNGP05.phx.gbl... > On 20/05/2010 11:16, Tony Johansson wrote: >> "Willem van Rumpt"<nothing(a)nowhere.com> skrev i meddelandet >> news:e$Bg2MA%23KHA.5464(a)TK2MSFTNGP05.phx.gbl... >>> Tony Johansson wrote: >>>> Hi! >>>> >>>> Here I say minimum 1 o and maximum three o but here I have more then >>>> three o and this expression give true but >>>> it should give false according to me ? >>>> >>>> bool status = Regex.IsMatch("foooooood", "o{1,3}"); >>>> >>>> //Tony >>> >>> Because your criteria has multiple matches: >>> >>> f[ooo][ooo][o]d >>> >>> >>> -- >>> Willem van Rumpt >> >> But according to me means "o{1,3}" that I must have at least 1 o and >> maximum >> of three o. >> I meam what is the purpose of using a max of 3 here then ? >> >> //Tony >> >> > > Hi Tony. > You have to specify that the previous/next letter can't be an "o". > > I am not an expert on regex but this should work > > [^o]o{1,3}[^o] > I don't want a solution I want to know why this regular expression does not work as I expect. But according to me means "o{1,3}" that I must have at least 1 o and maximum of three o. I meam what is the purpose of using a max of 3 here then ? //Tony
|
Next
|
Last
Pages: 1 2 3 4 Prev: Porting ASP.NET/SQL Server to JAVA/Oracle Next: [^o]o{1,3}[^o] is wrong :-/ |