codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php // Simple wildcard matching function function wildcard_match($pattern, $haystack) { $tokens = explode("*", $pattern); foreach($tokens as $token) { if( strlen($token) == 0 ) continue; $t = strpos($haystack, $token); if( $t !== false && $t >= $x ) $x = $t; else return false; } return true; } $s = "Hello Joe and Jane"; $p = "Hello * and *"; var_dump( wildcard_match($p, $s) );
Private
[
?
]
Run code
Submit