Reputation: 61775
I have the regexp:
\[IN\](\d+)\[/IN\]
Which works fine for:
...[IN]34[/IN]...
...[IN]1[/IN]...
...[IN]12[/IN]...
etc
But it doesn't quite work for decimals, IE:
...[IN]3.5[/IN]... ...[IN]2.8[/IN]... ...[IN]9.4[/IN]... etc
How do I make it match these as well?
Thanks!
Upvotes: 1
Views: 204
Reputation: 47068
Something like this
[IN](\d+|\d+\.\d+)?[/IN]
This ensures that you have a number after the dot if you have a dot.
Upvotes: 0
Reputation: 5138
From the top of my head i think it should be this:
[IN](\d+\.?\d*)[/IN]
EDIT: tested and corrected version:
\[IN\](\d+(\.\d+)?)\[\/IN\]
Upvotes: 2
Reputation: 54342
It doesn't check if it is valid float (have one decimal dot):
([\d.]+)
Upvotes: 2