怎么样:
^[1-9]\d*(?:\.\d+)?$
解释:
^ the beginning of the string
----------------------------------------------------------------------
[1-9] any character of: '1' to '9'
----------------------------------------------------------------------
\d* digits (0-9) (0 or more times (matching
the most amount possible))
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the most amount possible)):
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
----------------------------------------------------------------------
)? end of grouping
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
你的正则表达式^[(1-9)(\.)]\d*$
意味着:
^ the beginning of the string
----------------------------------------------------------------------
[(1-9)(\.)] any character of: '(', '1' to '9', ')',
'(', '\.', ')'
----------------------------------------------------------------------
\d* digits (0-9) (0 or more times (matching
the most amount possible))
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
----------------------------------------------------------------------
) end of grouping