Efficient String Replacement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
abreksa4
Forum Newbie
Posts: 2
Joined: Sun Jan 05, 2014 9:51 pm
Location: America

Efficient String Replacement

Post by abreksa4 »

Is there any way to make this chunk of code more efficient? I'm not looking for someone to write my code for me, just to point me in the right direction...

Code: Select all

        $string = preg_replace('/<ref[^>]*>([\s\S]*?)<\/ref[^>]*>/', '', $string);
        $string = preg_replace('/{{(.*?)\}}/s', '', $string); 
        $string = preg_replace('/File:(.*?)\\n/s', '', $string);
        $string = preg_replace('/==(.*?)\=\\n/s', '', $string);        
        $string = str_replace('|', '/', $string);
        $string = str_replace('[[', '', $string);
        $string = str_replace(']]', '', $string);
        $string = strip_tags($string);
Thanks in advance!
User avatar
abreksa4
Forum Newbie
Posts: 2
Joined: Sun Jan 05, 2014 9:51 pm
Location: America

Re: Efficient String Replacement

Post by abreksa4 »

Well, some very nice users over at stackoverflow were able to answer my question...

Here's the link if anyone else has the same question: http://stackoverflow.com/questions/2097 ... ent-in-php
Post Reply