My code was
if(eregi($pattern,$file)){
$out['file'][]=$file;
}else
But is doesn’t work in php 5.3, it shows the alert
Function eregi() is deprecated
so I changed to
if(preg_match($pattern,$file)){
$out['file'][]=$file;
}else
But now it shows
preg_match(): No ending delimiter '.' found
Did I enter any wrong syntax?
The pattern needs to have some sort of delimiter character surrounding it.
/is typical, but “any non-alphanumeric, non-backslash, non-whitespace character” could be used. Just make sure your delimiter character doesn’t appear in the$patternitself.So if your pattern was
http://(.*), which already has/characters in it, you might want to choose something else like~:Alternatively, as @jensgram notes below, if you can’t guarantee your pattern won’t contain a certain delimiter character, you could escape those characters in the pattern with preg_quote(), like so:
Oh, also, since you’re using
eregi()(case-insensitive), you’ll want to add theimodifier for case-insensitive to your pattern, outside the delimiter.