|
|
Invisible <voi### [at] devnull> wrote:
> > ^[+-]?([0-9]+\.?|[0-9]*\.[0-9]+)(e[+-]?([0-9]+\.?|[0-9]*\.[0-9]+))?$
> ...which would be incorrect then, for at least the following reasons:
> - There can be *zero* or more characters before the decimal point.
Which is exactly what "[0-9]*\." means: Zero or more digits, followed
by the dot character.
> - The "e" can also be "E".
That's easy to fix: Replace "e" in the regexp with "[eE]".
> - The exponent is an integer, not a real.
Then it becomes simpler:
^[+-]?([0-9]+\.?|[0-9]*\.[0-9]+)([eE][+-]?[0-9]+)?$
In fact, that pattern actually matches the floating point number
representation in C and C++ (except perhaps for possibility of a
preceding +).
> See? Not as easy as it looks, is it?
It was not a question of difficulty. It was a question of me not knowing
the exact format of floating point numbers in PostScript and making
assumptions.
--
- Warp
Post a reply to this message
|
|