Give you a character string s and a law p, invite you to implement a support '' and '*' in the regular expression matching.
'.' Matches any single character
'*' matches zero or more of the preceding element that a
so-called matching, to cover the entire string s, and not part of the string.
Description:
s may be empty, and only lowercase letters az from the.
p may be empty and contain only lowercase letters from az, and characters. and *.
Example 1:
Input:
S = "AA"
P = "A"
Output: false
interpretation: "a" can not match the entire string "aa".
Example 2:
Input:
S = "AA"
P = "A *"
Output: true
explanation: because the '*' matches zero or representatives of the foregoing that a plurality of elements, this is in front of the element 'a'. Thus, the string "aa" may be regarded as 'a' is repeated once.
Example 3:
Input:
S = "ab &"
P = "*."
Output: true
explained: ". *" Denotes zero or more matches ( '*') of any character ( '.').
Example 4:
Input:
S = "AAB"
P = "C * A * B"
Output: true
explanation: because the '*' means zero or more, where 'c' is 0, 'a' is repeated once. So it can match the string "aab".
Example 5:
Input:
S = "Mississippi"
P = "MIS * IS * P *."
Output: false
Source: stay button (LeetCode)
This problem a little difficult, steal someone else's answer