This is hard. It's not just a problem of using RegExp.
https://leetcode.com/problems/regular-expression-matching/
var isMatch = function (s, p) {
if (!s && !p) return true;
if (p[1] === "*") {
let pn = p.slice(2);
let sn = s;
while (true) {
if (isMatch(sn, pn)) return true;
if (!sn) break;
if (p[0] !== "." && sn[0] !== p[0]) break;
sn = sn.slice(1);
}
return false;
}
if (!s || !p) return false;
if (p[0] === "." || p[0] === s[0]) {
return isMatch(s.slice(1), p.slice(1));
}
return false;
};