Implement regular expression matching.
In a regular expression:
a-z matches the corresponding character.. matches any single character.* matches zero or more of the preceding character.The entire input string should be matched.
The function would take a string s and the regular expression pattern p.
s: "a"
p: "a"
match: true
s: "aa"
p: "a"
match: false
s: "ab"
p: "a."
match: true
s: "aa"
p: "a*"
match: true
s: "b"
p: "ba*"
match: true
s: "aabcd"
p: "a*b*c*d*"
match: true
The first line contains an integer âTâ, denoting the number of test cases.
For each test case the input has two strings s and p.
For each test case, a line containing true or false depending on the match.
6
a a
aa a
ab a.
aa a*
b ba*
aabcd a*b*c*d*
true
false
true
true
true
true
1 <= T <= 1001 <= s.length <= 201 <= p.length <= 20.', '*' and lowecase english alphabets.*' will always be preceded by a valid character.