愚蠢的人类,我还会再回来的……哈哈哈哈……【上升飘走……】# Joke - 肚皮舞运动
h*8
1 楼
The basic idea is fill in a table for a matching path. If the last pair
matches, the whole string will match.
match[i][j] is the array (to match string[i] with pattern[j]), which is of (
string length + 1)*(pattern length + 1).
match[0][*] and match[*][0] is padded with false.
Then the function is something like:
match[i][j] =
1. if pattern char='.', match[i][j]=match[i-1][j-1]
2. if pattern char='*', match[i][j]=match[i][j-1] //match 0 character
||match[i-1][j] //match any character
3. if pattern char=string char, match[i][j]=match[i-1][j-1]
4. otherwise, not matched.
大家看看对不对?
matches, the whole string will match.
match[i][j] is the array (to match string[i] with pattern[j]), which is of (
string length + 1)*(pattern length + 1).
match[0][*] and match[*][0] is padded with false.
Then the function is something like:
match[i][j] =
1. if pattern char='.', match[i][j]=match[i-1][j-1]
2. if pattern char='*', match[i][j]=match[i][j-1] //match 0 character
||match[i-1][j] //match any character
3. if pattern char=string char, match[i][j]=match[i-1][j-1]
4. otherwise, not matched.
大家看看对不对?