ShaolinF Posted May 2, 2010 Share Posted May 2, 2010 Hi Guys I have written some regex which is meant to replace certain BBcode tags with the HTML equiv. It is not working as I intended. See problem and code below: HTML I want to process: [quote][quote=Jack][quote=John]hello mate, how you doing?[/quote] Im fine thanks, you?[/quote] Im good.[/quote] PHP: $searchArray = array( '/(^\[quote=(.*)[\]]|\[quote\])/i', '/\[\/quote\]/i' ); $replaceArray = array( '<div class="quote">', '</div>' ); $message = preg_replace($searchArray, $replaceArray, $message); It should give me this output: <div class="quote"> <div class="quote"> <div class="quote"> hello mate, how you doing? </div> Im fine thanks, you? </div> Im good. </div> But instead I get this: <div class="quote"> [quote=Jack][quote=John]hello mate, how you doing? </div> Im fine thanks, you? </div> Im good. </div> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 Try this Replace: '/(^\ ]|\[quote\])/i', With: '/(^\ ]+\]|\[quote\])/i', Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.