One line Python regular expression solution


  • 0
    H
    return None != re.fullmatch(" *[+-]?(\d+|\d+\.\d*|\.\d+)(e[+-]?\d+)? *", s)
    

    The system would automatically generate a DFA for this regular expression and scan the string with only one pass before it returns the result.


Log in to reply
 

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