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> Link to comment https://forums.phpfreaks.com/topic/200449-regex-help/ 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', Link to comment https://forums.phpfreaks.com/topic/200449-regex-help/#findComment-1051962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.