1. Mandatory sign, integer, fraction, and exponent
^[-+][0-9]+\.[0-9]+[eE][-+]?[0-9]+$
2. Mandatory sing, integer, and fraction, but no exponent
^[-+][0-9]+\.[0-9]+$
3. Optional sign, mandatory integer and fraction, and no exponent
^[-+]?[0-9]+\.[0-9]+$
4. Optional sign and integer, mandatory fraction, and no exponent
^[-+]?[0-9]*\.[0-9]+$
5. Optional sign, integer, and fraction.
If the integer part is omitted, the fraction is mandatory.
If the fraction is omitted, the decimal dot must be omitted, too. No exponent
^[-+]?([0-9]+(\.[0-9]+)?|\.[0-9]+)$
6. Optional sign, integer, and fraction.
If the integer part is omitted, the fraction is mandatory.
If the fraction is omitted, the decimal dot is optional. No exponent
^[-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+)$
7. Optional sign, integer, and fraction.
If the integer part is omitted, the fraction is mandatory.
If the fraction is omitted, the decimal dot must be omitted, too. Optional exponent
^[-+]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][-+]?[0-9]+)?$
8. Optional sign, integer, and fraction.
If the integer part is omitted, the fraction is mandatory.
If the fraction is omitted, the decimal dot is optional. Optional exponent
^[-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][-+]?[0-9]+)?$
9. find float number in a larger body of text
[-+]?(\b[0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][-+]?[0-9]+\b)?
Python 正则表达式验证浮点数
最新推荐文章于 2024-08-14 14:25:41 发布