| @@ 199-211 (lines=13) @@ | ||
| 196 | * @param string $rule |
|
| 197 | * @return boolean |
|
| 198 | */ |
|
| 199 | function MatchWildcard ($str, $rule) { |
|
| 200 | // Convert wildcard rule to regex |
|
| 201 | $rule = str_replace('*', '.+', $rule); |
|
| 202 | $rule = str_replace('?', '.{1}', $rule); |
|
| 203 | $rule = '/' . $rule . '/'; |
|
| 204 | ||
| 205 | if (1 == preg_match($rule, $str, $ar_match)) |
|
| 206 | // Must match whole string, same length |
|
| 207 | if (strlen($ar_match[0]) == strlen($str)) |
|
| 208 | return true; |
|
| 209 | ||
| 210 | return false; |
|
| 211 | } // end of func MatchWildcard |
|
| 212 | ||
| 213 | ||
| 214 | /** |
|
| @@ 278-293 (lines=16) @@ | ||
| 275 | * @param string $rule |
|
| 276 | * @return boolean |
|
| 277 | */ |
|
| 278 | public function matchWildcard($str, $rule) |
|
| 279 | { |
|
| 280 | // Convert wildcard rule to regex |
|
| 281 | $rule = str_replace('*', '.*', $rule); |
|
| 282 | $rule = str_replace('?', '.{1}', $rule); |
|
| 283 | $rule = '/' . $rule . '/'; |
|
| 284 | ||
| 285 | // Must match whole string, same length |
|
| 286 | if ((1 == preg_match($rule, $str, $matches)) |
|
| 287 | && (strlen($matches[0]) == strlen($str)) |
|
| 288 | ) { |
|
| 289 | return true; |
|
| 290 | } else { |
|
| 291 | return false; |
|
| 292 | } |
|
| 293 | } |
|
| 294 | ||
| 295 | ||
| 296 | /** |
|