10. Regular Expression Matching
正則匹配
本題來自LeetCode OJ
題目翻譯
Implement regular expression matching with support for '.'
and '*'
.
實現正則表達式匹配,支持'.'
和'*'
。
'.' Matches any single character.
'.' 匹配任何單個字符。
'*' Matches zero or more of the preceding element.
'*' 匹配0個或多個前面的元素
The matching should cover the entire input string (not partial).
匹配應該覆蓋整個輸入字符串(不是部分)。
The function prototype should be:
函數原型應該是:
bool isMatch(const char *s, const char *p)
Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "a*") → true
isMatch("aa", ".*") → true
isMatch("ab", ".*") → true
isMatch("aab", "c*a*b") → true