Archive for 十一月, 2009

[一道面试题]含有*的字符串匹配问题

5 Comments »

Question

字符串1:只含有英文字母
字符串2:含有英文字母和*,其中符号*表示匹配任意字符0或者多次,即正则表达式里面的含义。

现在给定这样的两个串,要求判断是否匹配?
bool isMatch ( const char *str1, const char *str2)

例如:str1 = “hello”, str2 = “he*o”,则二者匹配,返回true,str1 = “hello”, str2 = “he*l”,则不匹配,返回false。

Read the rest of this entry »