scanreg Posted August 11, 2009 Share Posted August 11, 2009 I know you need to escape square brackets in regular expressions: \ \[\/url] However, in the following preg_replace there is this: $text = preg_replace('/\[b]([^[]+)\[\/b]/i', '<strong>$1</strong>', $text); My question is why aren't the square brackets inside the parens escaped? Should they be like this instead: $text = preg_replace('/\[b](\[^\[]+)\[\/b]/i', '<strong>$1</strong>', $text); Many thanks Link to comment https://forums.phpfreaks.com/topic/169773-escaping-square-brackets-in-preg_replace/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.