题目描述
请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配
题解:
这道题无法使用动态规划,因为不知道字符的长度;
嗯嗯,正则匹配我还是稀里糊涂 的,等弄明白了,再补充 ~待更新。。。
1 class Solution { 2 public: 3 bool match(char* str, char* pattern) 4 { 5 if (str == nullptr || pattern == nullptr)return false; 6 return matchCore(str, pattern); 7 } 8 bool matchCore(const char *str, const char *pattern) 9 { 10 if (*str == '