Skip to content

Commit eb39cad

Browse files
committed
Update valid-number.py
1 parent 382a56e commit eb39cad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/valid-number.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class InputType:
2121
DOT = 4
2222
EXPONENT = 5
2323

24-
# regular expression: "^\s*[\+\-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?\d+)?\s*$"
24+
# regular expression: "^\s*[+-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?\d+)?\s*$"
2525
# automata: http://images.cnitblog.com/i/627993/201405/012016243309923.png
2626
class Solution:
2727
# @param s, a string
@@ -63,11 +63,11 @@ class Solution2:
6363
# @return a boolean
6464
def isNumber(self, s):
6565
import re
66-
return bool(re.match("^\s*[\+\-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?\d+)?\s*$", s))
66+
return bool(re.match("^\s*[+-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?\d+)?\s*$", s))
6767

6868
if __name__ == "__main__":
6969
print Solution().isNumber(" 0.1 ")
7070
print Solution().isNumber("abc")
7171
print Solution().isNumber("1 a")
7272
print Solution().isNumber("2e10")
73-
73+

0 commit comments

Comments
 (0)