dallypost Posted February 10, 2009 Share Posted February 10, 2009 I have a block of text stored in a string that includes [keywords]some random text[/keywords] I want to replace [keywords], [/keywords] and everything in between with "" (nothing) I have been trying many versions of this: $string=ereg_replace("regex expression", "", $string); Nothing seems to work. I know that this is probably pretty basic but regular expressions just about kill me. Thanks for your help Lance Quote Link to comment https://forums.phpfreaks.com/topic/144703-ereg_replace-remove-text-that-begins-with-___-and-ends-with-___/ Share on other sites More sharing options...
.josh Posted February 11, 2009 Share Posted February 11, 2009 $string = preg_replace('~\[keywords\].*?\[/keywords\]~','',$string); Quote Link to comment https://forums.phpfreaks.com/topic/144703-ereg_replace-remove-text-that-begins-with-___-and-ends-with-___/#findComment-759376 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.