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
https://forums.phpfreaks.com/topic/157012-solved-regex-code-not-working/
Share on other sites

Thanks for the help, but it still doesn't work.

 

http://gphosting.net/test2.php

 

There's a link to the script, the link at the top will show you all the code.

 

Only the first textbox has the code enabled, but it just ignores the preg_replace and outputs whatever the str_replace did.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.