Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve this question in C not python. please solve this question in C and not python. ROBLEM 2: (Regular Expression) In the lecture, you

image text in transcribed

please solve this question in C not python. please solve this question in C and not python.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago