We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

preg_replace help

Development and Programming

Chris Williams's avatar
Chris Williams
102 posts
17 years ago
Chris Williams's avatar Chris Williams

I’ve got to be getting this wrong. I’m not very well versed in reg expressions so I’m hoping someone can lend me a set of eyes.

I’m trying to pass {body} to a plug in and then replace the first with . And from all the php forums I’ve scoured I’ve come up with this:

$str = preg_replace('//i', '', $str, 1);
       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

Try adding ? after the *

       
Chris Williams's avatar
Chris Williams
102 posts
17 years ago
Chris Williams's avatar Chris Williams

That works! Thanks!

class Formatstory {
    var $return_data;
    function Formatstory($str = "")
    {    
        global $TMPL;
        if ($str == '')
        {
            $str = $TMPL->tagdata;
        }
        $this->return_data = preg_replace('/', $str, 1);
    }
}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.