Python Regex


  • 0
    D
    class Solution(object):
        def isNumber(self, s):
            """
            :type s: str
            :rtype: bool
            """
            import re
            s = s.strip()
            p = r"\A[-+]?((\d*\.?\d+)|(\d+\.?\d*))(e[-+]?\d+)?\Z"
            return bool(re.match(p, s, re.I))
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.