Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: Floating Point/Integer Regular Expression

by shortyfw06 (Beadle)
on Jul 25, 2012 at 15:46 UTC ( #983691=note: print w/replies, xml ) Need Help??

in reply to Re: Floating Point/Integer Regular Expression
in thread Floating Point/Integer Regular Expression

Thank you. That is a useful function! I ended up answering my own question for a regex that includes negative/positive integers and negative/positive floating points.


And just for clarification, this is used as a -validatecommand.

Replies are listed 'Best First'.
Re^3: Floating Point/Integer Regular Expression
by tobyink (Abbot) on Jul 25, 2012 at 23:45 UTC

    Did you know that regexp matches:

    • -
    • 1.

    But fails to match:

    • .1
    • -.1

    You might want to try this. It's somewhat simpler than yours, and it disallows the single hyphen, but allows decimals which start with the decimal point and no preceding 0.


    Or if you consider a leading/trailing decimal point to be an error, it can be made simpler:

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://983691]
[LanX]: morning
marto waves
[Discipulus]: if you prepend 'good' to this mere part of the day you get a in good morning LanX
[LanX]: good
[LanX]: ;-p
[Eily]: good mere part of the day to you too

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2018-02-20 10:37 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (268 votes). Check out past polls.