Simple JavaScript Code and easy to understand!


  • 0
    W
    var isMatch = function(s, p) {
        // .代表任意字符, *代表0到多次
        if (!p.match(/\.|\*/)) {
            return s === p;
        }
        var regResult = s.match(new RegExp(p));
        return regResult !== null && regResult[0] === regResult['input'];
    };
    

Log in to reply
 

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