Write a function to process regular expression with letter, ".", "*".
Anonimo
BOOL compare(char r, char s) { return r == s || r == '.'; } BOOL match(char* regex, char* str) { while (TRUE) { // have we reached the end of the string if (regex[0] == 0 && str[0] == 0) return TRUE; else if (regex[0] == 0 || str[0] == 0) return FALSE; if (regex[1] == '*') { // Test if missing completely if (match(regex+2, str)) return TRUE; if (compare(regex[0],str[0])) { if (match(regex, str+1)) return TRUE; } regex += 2; } else if (compare(regex[0],str[0])) { regex++; str++; } else { return FALSE; } } }