Question: please help solve this in C ROBLEM 2: (Regular Expression) In the lecture, you have learned about pattern checking (e.g., grep -e [regexp] [files]). In

please help solve this in C
ROBLEM 2: (Regular Expression) In the lecture, you have learned about pattern checking (e.g., grep -e [regexp] [files]). In fact, the pattern is in the form of regular expression. In this problem, we consider a simplified parser to check whether a string (str) matches a regular expression (expr) with the following special symbols in the pattern: - matches any single character - * matches 0 or more of the preceding element Your program reads two words as input. The first one is the string to be checked. The second one is the simplified regular expression string. Print "True" if the entire string matches the expression, or "False" otherwise. Constraints: - The length of str and expr is in the range [0,20] - The string str only contains English letters and digits - The string expr only contains English letters, digits, . and "*' - For each '*', there must be a previous valid character to match Example 1: Input: IERG2080 IERG.* Output: True Reason: The '.' appears 4 times, where each '.' can be any character. Example 2: Input: Apple Ap*les* Output: True Reason: The ' p ' appears twice, and the ' s ' never appears. Example 3: Input: aaaa Haa Output: True Reason: The a* matches the middle 3 'a's. Example 4: Input: Tutorial2 Tutorial Output: False Reason: The entire string does not match. Hints: - Use recursion when there is a branch in the decision
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
