Jump to content

Warning: preg_replace(): Unknown modifier '('


terungwa
Go to solution Solved by requinix,

Recommended Posts

$text = preg_replace("/([^[])/me([^\n\r$]*)([\n\r$])/", "\\1<span class=\"me\">*".$ubbObj->username." \\2 *</span>\\3", $text); 
  $text = nl2br($text);
$text = preg_replace("([^[])/me([^\n\r$]*)([\n\r$])", "\\1[me=".$this->username."]\\2[/me]\\3", $text);

I was editing the code bit above (converting eregi_replace to preg_replace) but i am getting a warning: Warning: preg_replace(): Unknown modifier '('

could you help me resolve the right regex synthax.

 

Thanks.

Link to comment
Share on other sites

  • Solution

If you use / delimiters then you have to make sure you escape them inside the expression (or not even use them at all).

 

~ and # are common alternatives.

"#([^[])/me([^\n\r$]*)([\n\r$])#"
Edited by requinix
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.