Skip to content

Commit

Permalink
[python[js]]00010.regular-expression-matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Huauauaa committed Aug 31, 2024
1 parent 60c82e3 commit 42c1ae9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/leetcode/00010.regular-expression-matching/10.js
Original file line number Diff line number Diff line change
@@ -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', '.*'));
12 changes: 12 additions & 0 deletions src/leetcode/00010.regular-expression-matching/10.py
Original file line number Diff line number Diff line change
@@ -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*"))

0 comments on commit 42c1ae9

Please sign in to comment.