Reputation: 39
As i mentioned in title i am getting the error of *Warning: preg_replace(): Compilation failed:* which is really weird for me;
actually on the VPS of godaddy i moved my site; first i got an error of GD library; so i installed GD library by using easy apache from WHM,
then now when i m trying to run my website i am getting this warning, Warning: preg_replace(): Compilation failed: nothing to repeat at offset 5
on this page techchef.org/development/module/newsfeed/LoadDataFromFeed.php
however the same script runs on my another server which is techchef.org/development/module/newsfeed/LoadDataFromFeed.php and it works fine
here is the script i am not sure if it is because of apache settings, if yes then what actually i missed.
Below is the php script for which it mentioned the error
$str= strtolower($str);
$str= preg_replace("/(à|á|?|?|ã|â|?|?|?|?|?|a|?|?|?|?|?)/","a",$str);
$str= preg_replace("/(è|é|?|?|?|ê|??|?|?|?|?)/","e",$str);
$str= preg_replace("/(ì|í|?|?|i)/","i",$str);
$str= preg_replace("/(ò|ó|??|??|õ|ô|?|?|?|?|?|o|??|?|?|?|?)/","o",$str);
$str= preg_replace("/(ù|ú|?|?|u|u|?|?|?|?|?)/","u",$str);
$str= preg_replace("/(?|ý|?|?|?)/","y",$str);
$str= preg_replace("/(d)/","d",$str);
$str= preg_replace("/(!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_)/","-",$str);
$str= preg_replace("/(-+-)/","-",$str);
$str= preg_replace("/(^\-+|\-+$)/","",$str);
$str= preg_replace("/(-)/"," ",$str);
Upvotes: 0
Views: 4987
Reputation: 32272
When you copied the code from wherever you've munged the formatting/encoding.
$str= preg_replace("/(à|á|?|?|ã|â|?|?|?|?|?|a|?|?|?|?|?)/","a",$str);
// ^- offset 5
Educated guess, this [and all the other question marks] should be another a
-like character, and not a question mark. ?
is a metacharacter to do with repetition [0 or 1] and should be escaped for a literal ?
.
Same goes for the other expressions.
Upvotes: 3