BirdOPrey5
12-26-2010, 08:02 PM
What I need to do is when a message is quoted to replace one bb code inside the quote with another bb code...
So let's say the message data contains:
This is a test http://www.google.com more test. One more time http://www.yahoo.com
Hi. http://www.bing.com
Bye.
I would want it to change to:
This is a test http://www.google.com more test. One more time http://www.yahoo.com
Hi. http://www.bing.com
Bye.
The hooks and variables I'm sure I can figure out... and I've been pretty good making regular expressions with regex buddy these days...
I'm thinking preg_replace will be the key to doing this... to match and and replace with and only within a quote- but I have read the pho manual on preg_replace (http://php.net/manual/en/function.preg-replace.php) and wondering if there isn't more to it?
I found some info in this thread: https://vborg.vbsupport.ru/showthread.php?t=77173
But that code doesn't seem to work in 3.7/3.8...
EDIT
That line from that thread looks exactly like I want to do.., in class_bbcode.php after line 1424 I want to do a preg_replace on $html and change all the [cust] tags to [xxx] but this is never matching:
$html = preg_replace('#\[test\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/test\]#iue', "$1", $html);
Trying to change [test] to [ url ] in that example...
Edit AGAIN
It appears the problem is in 3.8 $html and $message are already converted to HTML so there are no bb code's left in the code at this point anymore, they have already been parsed.
--------------- Added 1293416282 at 1293416282 ---------------
Well I ended up just using str_replace, twice... Once to remove all the HTML in front of the {param} and replace it, and another to remove and replace all the code after the {param}... I was looking and I just don't see anywhere were the unparsed QUOTE only is available...
--------------- Added 1293417599 at 1293417599 ---------------
Wow... I found a mod that does everything I need really easily... at least this was a learning experience...
https://vborg.vbsupport.ru/showthread.php?t=191223 :up:
So let's say the message data contains:
This is a test http://www.google.com more test. One more time http://www.yahoo.com
Hi. http://www.bing.com
Bye.
I would want it to change to:
This is a test http://www.google.com more test. One more time http://www.yahoo.com
Hi. http://www.bing.com
Bye.
The hooks and variables I'm sure I can figure out... and I've been pretty good making regular expressions with regex buddy these days...
I'm thinking preg_replace will be the key to doing this... to match and and replace with and only within a quote- but I have read the pho manual on preg_replace (http://php.net/manual/en/function.preg-replace.php) and wondering if there isn't more to it?
I found some info in this thread: https://vborg.vbsupport.ru/showthread.php?t=77173
But that code doesn't seem to work in 3.7/3.8...
EDIT
That line from that thread looks exactly like I want to do.., in class_bbcode.php after line 1424 I want to do a preg_replace on $html and change all the [cust] tags to [xxx] but this is never matching:
$html = preg_replace('#\[test\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/test\]#iue', "$1", $html);
Trying to change [test] to [ url ] in that example...
Edit AGAIN
It appears the problem is in 3.8 $html and $message are already converted to HTML so there are no bb code's left in the code at this point anymore, they have already been parsed.
--------------- Added 1293416282 at 1293416282 ---------------
Well I ended up just using str_replace, twice... Once to remove all the HTML in front of the {param} and replace it, and another to remove and replace all the code after the {param}... I was looking and I just don't see anywhere were the unparsed QUOTE only is available...
--------------- Added 1293417599 at 1293417599 ---------------
Wow... I found a mod that does everything I need really easily... at least this was a learning experience...
https://vborg.vbsupport.ru/showthread.php?t=191223 :up: