From: Martin DeMello Date: 2008-06-20T08:01:11+09:00 Subject: Re: RegEx On Thu, Jun 19, 2008 at 3:48 PM, Mikael Høilund wrote: > > On Jun 20, 2008, at 0:12, Justin To wrote: > >> I'm stuck trying to write a regular expression for a percentage: >> >> Examples of what I'm trying to match: >> >> 1.1, 1.12, 12, 12.1 and 12.12 >> >> 0.00 <= float <= 100.00 >> > > > Perhaps try /\d?\d(\.\d\d?)?|100(\.00?)?/ (untested). fails for 2100.0123 - you need to anchor with ^ and $ or at least \D and \D also fails for .1 (though to be fair ruby rejects that too :)) martin