November 12th in PHP Scripts by pbu .

Fix-> Warning: ereg_replace(): REG_BADRPT in PHP

If you are a PHP programmer and if you are using regular expressions with ereg_replace then often with replacing particular characters you might encounter error like

Warning: ereg_replace(): REG_BADRPT

Here is a simple function that causes this error

function OrigURL($str)
{
$out = ereg_replace('+',' ',$str);
return $out;
}

Solution: Just escape the characters. Only then it will work.

$out = ereg_replace(‘\+’,’ ‘,$str);

Hope this would help!

Similar Posts:

Share and Enjoy:
  • del.icio.us
  • digg
  • StumbleUpon
  • Technorati
  • DZone
  • Facebook
  • FriendFeed
  • Reddit
  • RSS
  • Twitter

One Comment

  • iju
    January 23, 2009

Leave A Comment.