<qiyuangong>010_Regular_Expression_Matching_1.py
def isMatch( s, p):
    if s == p:
        return True
    m, n = len(s), len(p)
    dp = [[False] * (n + 1) for _ in range(m + 1)]
    dp[0][0] = True
    for j in range(1, n):
        if p[j] == '*' and dp[0][j - 1]:
            dp[0][j + 1] = True
    for i in range(m):
        for j in range(n):
            if p[j] == '.' or p[j] == s[i]:
                dp[i + 1][j + 1] = dp[i][j]
            elif p[j] == '*':
                if p[j - 1] != s[i] and p[j - 1] != '.':
                    dp[i + 1][j + 1] = dp[i + 1][j - 1]
                else:
                    dp[i + 1][j + 1] = dp[i + 1][j] or dp[i][j + 1] or dp[i + 1][j - 1]
    return dp[m][n]
def sample_funcname ( var_0 , var_1 ) :
    if var_0 == var_1 :
        return True
    var_4 , var_5 = len ( var_0 ) , len ( var_1 )
    var_10 = [ [ False ] * ( var_5 + 1 ) for var_8 in range ( var_4 + 1 ) ]
    var_10 [ 0 ] [ 0 ] = True
    for var_12 in range ( 1 , var_5 ) :
        if var_1 [ var_12 ] == '*' and var_10 [ 0 ] [ var_12 - 1 ] :
            var_10 [ 0 ] [ var_12 + 1 ] = True
    for var_14 in range ( var_4 ) :
        for var_12 in range ( var_5 ) :
            if var_1 [ var_12 ] == '.' or var_1 [ var_12 ] == var_0 [ var_14 ] :
                var_10 [ var_14 + 1 ] [ var_12 + 1 ] = var_10 [ var_14 ] [ var_12 ]
            elif var_1 [ var_12 ] == '*' :
                if var_1 [ var_12 - 1 ] != var_0 [ var_14 ] and var_1 [ var_12 - 1 ] != '.' :
                    var_10 [ var_14 + 1 ] [ var_12 + 1 ] = var_10 [ var_14 + 1 ] [ var_12 - 1 ]
                else :
                    var_10 [ var_14 + 1 ] [ var_12 + 1 ] = var_10 [ var_14 + 1 ] [ var_12 ] or var_10 [ var_14 ] [ var_12 + 1 ] or var_10 [ var_14 + 1 ] [ var_12 - 1 ]
    return var_10 [ var_4 ] [ var_5 ]
