lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 07/12/2010 11:03, Dirk Laurie wrote:
I'm writing an input checker for a non-Lua application.  It makes
liberal use of positive F-format real numbers, e.g. 3, .1, 3., 3.1.
Can one do that with just one pattern, assuming whitespace already
trimmed?

Funnily, I just wrote on the topic very recently (for Java, but the regexes still apply, more or less).

http://phi.lho.free.fr/serendipity/index.php?/archives/28-Is-this-string-a-number.html

Among other things, I point out that, when possible, it is better (simpler, faster) to use two (or more) REs with some logic around it than trying to do everything with one RE.

Now, sometime we take REs from some data source, so the programmatic way might not be possible.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --