diff --git a/src/leetcode/00010.regular-expression-matching/10.js b/src/leetcode/00010.regular-expression-matching/10.js new file mode 100644 index 0000000..05b3462 --- /dev/null +++ b/src/leetcode/00010.regular-expression-matching/10.js @@ -0,0 +1,13 @@ +/** + * @param {string} s + * @param {string} p + * @return {boolean} + */ +var isMatch = function (s, p) { + const reg = new RegExp(`^${p}$`); + return reg.test(s); +}; + +console.log(isMatch('aa', 'a')); +console.log(isMatch('aa', 'a*')); +console.log(isMatch('ab', '.*')); diff --git a/src/leetcode/00010.regular-expression-matching/10.py b/src/leetcode/00010.regular-expression-matching/10.py new file mode 100644 index 0000000..689021e --- /dev/null +++ b/src/leetcode/00010.regular-expression-matching/10.py @@ -0,0 +1,12 @@ +import re + + +class Solution: + def isMatch(self, s: str, p: str) -> bool: + + return False if re.match(f"^{p}$", s) == None else True + + +if __name__ == "__main__": + print(Solution().isMatch("aa", "a")) + print(Solution().isMatch("aa", "a*"))