Jump to content

[SOLVED] Regex code not working...


ShadeSlayer

Recommended Posts

I have a code that I'm using to replace this:

    Team Player (10 points): Complete a mission on coop mode. 

 

With this:

[adminbr][b]Team Player[/b] - [i]10 points[/i][adminbr][adminbr]

 

So I have the code there that does the job fine.. unless there are parenthesis elsewhere (eg. Team Player (10 points): Complete a mission on coop mode (not XBL).

 

Basically, one part of the replacement is taking an opening parenthesis tag and replacing it with the appropriate values, but then, it needs to be fixed for certain situations.

 

So I tried this:

 

$s = $_POST['string'];
$p[0] = "    ";
$r[0] = "[adminbr][adminbr][b]";
$p[1] = "): ";
$r[1] = "[/i][adminbr]";
$p[2] = "\\\"";
$r[2] = "\"";
$p[3] = "\'";
$r[3] = "'";
$str = str_replace($p, $r, $s); //, $string
$ereg = eregi_replace(" [\(]^[0-9]{1,3}$", "[/b] - [i]", $str);

echo $ereg;

 

Which says "replace " (###" with "[/b] - [i]" and it completely ignores the $ereg.

 

So I have a bit of a problem here that I need help with. Much appreciated.

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.