aebstract Posted March 1, 2010 Share Posted March 1, 2010 (Didn't realize my other post wasn't in the right section!) $article = eregi_replace("^([[(a-zA-Z0-9.)]]{1,})", "", $article); Trying to get the hang of regex, but I'm failing atm. Need to remove everything from $article that matches [[anythinggoeshere.anyextension]] this pattern. The above code doesn't do anything Quote Link to comment https://forums.phpfreaks.com/topic/193808-trying-to-replace-specific-tags-and-everything-inside/ Share on other sites More sharing options...
cags Posted March 1, 2010 Share Posted March 1, 2010 If you are trying to learn Regex I suggest you scrap eregi as it is a deprecated function, instead you will want to be using preg_match/replace. Try... preg_replace('#\[[a-z0-9]+\.[a-z0-9]+]#i', '', $article); Quote Link to comment https://forums.phpfreaks.com/topic/193808-trying-to-replace-specific-tags-and-everything-inside/#findComment-1020060 Share on other sites More sharing options...
aebstract Posted March 1, 2010 Author Share Posted March 1, 2010 If you are trying to learn Regex I suggest you scrap eregi as it is a deprecated function, instead you will want to be using preg_match/replace. Try... preg_replace('#\[[a-z0-9]+\.[a-z0-9]+]#i', '', $article); Alright. Had to add in an extra bracket: $article = preg_replace('#\[[[a-z0-9]+\.[a-z0-9]+]]#i', '', $article); Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/193808-trying-to-replace-specific-tags-and-everything-inside/#findComment-1020065 Share on other sites More sharing options...
cags Posted March 1, 2010 Share Posted March 1, 2010 Ooops, my bad, didn't realise you had the two sets. Quote Link to comment https://forums.phpfreaks.com/topic/193808-trying-to-replace-specific-tags-and-everything-inside/#findComment-1020069 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.