--- Begin Message ---
- Subject: Patterns problem
- Date: Mon, 28 Jul 2003 12:10:57 +0100
Hi,
I'm using Lua 5 to do some work and I can't get a pattern to do what I
want.
For those perlites among us, the regexp I'm trying to replicate is:
^\-?\d+(?:\.\d\d)?$
I.E. an optional leading minus, then at least one digit.
then optionally, a decimal point followed by exactly two digits.
I don't care if it captures or not, but I don't need the capture.
My first try, created the pattern:
^%-?%d+(%.%d%d)?$
But that refused to match anything. Particularly the ? after the ()s
seemed to confuse matters.
Currently I have a logic workaround of the form
^%-?%d+$ and ^%-?%d+%.%d%d$ as a pair of patterns which I test in
turn.
This is plainly not ideal.
Any ideas?
D.
--
Daniel Silverstone http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org KeyId: 20687895
Tonight's the night: Sleep in a eucalyptus tree.
--- End Message ---