c********e 发帖数: 383 | 1 trying to do a regex match on non-zero number.
match : 1.5 0.5 0.9 9.0 90
not match : 0 0.0
but could not find an elegant solution. Any suggestion? thx |
c**t 发帖数: 2744 | 2 match all numbers then exclude 0 or 0.0?
【在 c********e 的大作中提到】 : trying to do a regex match on non-zero number. : match : 1.5 0.5 0.9 9.0 90 : not match : 0 0.0 : but could not find an elegant solution. Any suggestion? thx
|
c****j 发帖数: 802 | 3 a stupid way:
"[1-9]\d*\.\d*|[^.][1-9]\d*[^.]|[0]\.\d*[1-9]\d*"
(fraction begin with 1-9|integer begin with 1-9|fraction begin with0)
【在 c********e 的大作中提到】 : trying to do a regex match on non-zero number. : match : 1.5 0.5 0.9 9.0 90 : not match : 0 0.0 : but could not find an elegant solution. Any suggestion? thx
|
m******t 发帖数: 2416 | 4
Try:
(0*[1-9]\d*(\.\d)?\d*)|(0*\.0*[1-9]\d*)
【在 c********e 的大作中提到】 : trying to do a regex match on non-zero number. : match : 1.5 0.5 0.9 9.0 90 : not match : 0 0.0 : but could not find an elegant solution. Any suggestion? thx
|