Roop <> wrote:
> I want to ask regading regular expression.
> I want to use such regular expression which only allow integers and
> float value.
> for example :--
> 12
> 12.34
> 23.456
> 0.5
> 0.0
> 0
> I found but not able to find. Please Help me . Suggest me the regular
> expression for that
Lets take this step by step... based on your examples...
m/^\d+ # At least one digit (and nothing else) to start the value
(?: # Start a cluster but don't capture
\.\d+ # We may have a decimal point followed by at least one digit
)? # The decimal point + following digits may occur either
# once or not at all
$ # Nothing else can follow
/x; # And allow whitespace and comments in the RE
This allows all your examples, but not for example: 5.
as it does not have a following digit.
Axel
|