Brandon_R Posted August 8, 2009 Share Posted August 8, 2009 Hello Guys im looking for a regex that will replace EVERYTHING after the first world in bold <b>whatever</b> tags to nothing (deletes it or replaces it with a space). The regex searches for the first bold word or tags and once found, deletes that together with everything that follows. Thank You Brandon_R Quote Link to comment Share on other sites More sharing options...
thebadbad Posted August 8, 2009 Share Posted August 8, 2009 Couldn't you just remove everything from and including the first occurrence of <b>, with the built in string functions? $str = substr($str, 0, stripos($str, '<b>')); Quote Link to comment Share on other sites More sharing options...
Brandon_R Posted August 8, 2009 Author Share Posted August 8, 2009 *Knocks my head Thanks, must of crossed my mind. Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 9, 2009 Share Posted August 9, 2009 Or, for a regex solution, use $Content = preg_replace('~<b>(.*?)</b>(.*?)$~/s', '', $Cotent); Quote Link to comment Share on other sites More sharing options...
Adam Posted August 18, 2009 Share Posted August 18, 2009 Or, for a regex solution, use $Content = preg_replace('~<b>(.*?)</b>(.*?)$~/s', '', $Cotent); You don't need the slash before the 's' modifier, but I'd go with the non-regex option in this case. 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.