I am trying to match some link from some texts:
$reg = '#ok is it http://google.com/?s=us#';
$page = 'Well i think ! ok is it http://google.com/?s=us&ui=pl0 anyways it ok';
if(preg_match($reg,$page)){
echo 'it work';
}else{
echo 'not work';
}
Now the problem is , if i use $reg = '#ok is it http://google.com/'; then its ok but when i use that one with “?=” it doesnt.
ok ! i understand there is some problem of syntax error is there any function or ready made function which automatically escape these special characters ?
You have a lot of syntax errors. You must escape all the special chars as ‘.’, ‘?’ and so on. Thus you have to replace the chars like this:
Anyway, the regex should be like this: