Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
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
<script src="https://code.youkuaiyun.com/snippets/633813.js"></script>

本文介绍了一种实现正则表达式匹配的方法,支持‘.’和‘*’两种特殊字符。‘.’可以匹配任意单个字符,而‘*’则可以匹配其前一个元素的零次或多次出现。文章通过几个实例演示了如何使用该方法来判断一个字符串是否能被特定的正则表达式完全匹配。
1529

被折叠的 条评论
为什么被折叠?



