bronto has asked for the wisdom of the Perl Monks concerning the following question:
Starting to elucubrate from these nodes and perlnumber, I am wondering: which pattern (or patterns) cover any possible valid string representation of a number in Perl, leaving version numbers out?
What about these?
- Integer: ^\s*[+-]?\d+\s*$
- Binary: ^\s*[+-]?0b[0-1]+\s*$
- Octal: ^\s*[+-]?0[0-7]+\s*$
- Hexadecimal: ^\s*[+-]?0x[0-9a-fA-F]+\s*$
- With decimals: ^\s*[+-]?\d+\.\d*\s*$
- Exponential: ^\s*[+-]?\d+(\.\d*)?[Ee][+-]?\d+$
Ciao!
--bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Patterns for your numbers
by adrianh (Chancellor) on Feb 07, 2003 at 11:13 UTC | |
by bronto (Priest) on Feb 07, 2003 at 12:50 UTC | |
Re: Patterns for your numbers
by jryan (Vicar) on Feb 07, 2003 at 16:19 UTC |
Back to
Seekers of Perl Wisdom