python solution using re module..........


  • 0
    P
    import re
    class Solution(object):
        def isMatch(self, s, p):
            """
            :type s: str
            :type p: str
            :rtype: bool
            """
            p=p.lstrip("*")
            def fullmatch(regex, string, flags=0):
                return re.match("(?:" + regex + r")\Z", string, flags=flags)
            if fullmatch(p,s):
                return True
            return False
    

    just for fun~~


Log in to reply
 

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