Help with ereg_replace function

Discussion forum for MOD Writers regarding MOD Development.
Locked
sbourdon
Registered User
Posts: 174
Joined: Sat Nov 13, 2004 6:29 pm

Help with ereg_replace function

Post by sbourdon »

Hello,

Since I've installed the HTML BBCode on my board, I would like to get rid of all code between the [html:xxx] and [/html:xxx] brackets for all posts emailed to users.

I don't understand the ereg_replace and preg_replace functions quite well, but by looking at existing code and using a trial and error method, I was able to come up with this:

Code: Select all

$post_text = trim( ereg_replace("[html:([a-zA-Z0-9])](.*?)[/html:([a-zA-Z0-9])]", "", $post_text ) );
Unfortunately, it does return an error message:

Code: Select all

ereg_replace() [function.ereg-replace]: REG_BADRPT in ...
Could someone tell me what I should change in that line for it to work as expected?


Thank you very much for your help! :)
sbourdon
Registered User
Posts: 174
Joined: Sat Nov 13, 2004 6:29 pm

Re: Help with ereg_replace function

Post by sbourdon »

Fixed using the following code:

Code: Select all

$post_text = preg_replace("#\[html:([a-zA-Z0-9]+)\](.*?)\[/html:([a-zA-Z0-9]+)\]#si", "". $lang['digest_html_text'] ."", $post_text);
Hope this will help others! :mrgreen:
Locked

Return to “[3.0.x] MOD Writers Discussion”