pandailo Posted July 16, 2008 Share Posted July 16, 2008 Hi all, i having a problem with eregi_replace below...its really NOT working... $str = eregi_replace("[-a-z0-9!#$%&\'*+/=?^_`{|}~](dot[ ]*)(com|org|net|biz|mobi|mobile|0rg|c0m)", "SPAMMING ARE PROHIBITED! ", $str); Actually if somebody try to type blabla dot com, it will replace with word SPAMMING ARE PROHIBITED but then above statement not working at all. Somebody can help Quote Link to comment Share on other sites More sharing options...
pandailo Posted July 16, 2008 Author Share Posted July 16, 2008 sorry second post, im not only wanted to replace blabla dot com but also blabla d0t com, blabla d0t c0m, blabladotcom, blablad0tc0m, b l a d o t c o m and b,l,a,b,l,a,d,o,t,c,o,m can somebody help me? Quote Link to comment Share on other sites More sharing options...
effigy Posted July 16, 2008 Share Posted July 16, 2008 Your request is very open-ended, which will be difficult to field without (a) some mistakes, or (b) a slow down. Specifically, I'm talking about the varying spaces. For instance, how do you know that " a " is part of an URL and not the letter "a"? Because it's surrounded by single letters? Then the culprit could use "bl ad ot co m." Do you have any idea how big this string will be? See similar concerns here and here. Quote Link to comment Share on other sites More sharing options...
pandailo Posted July 17, 2008 Author Share Posted July 17, 2008 yeah you have good point there but my initial stage is to detect URL base on word "dot" and follow by international domain "com", etc etc...doesnt matter how does it looks like in front. Anyway i manage to solve it partially like below.. $str = eregi_replace("([-a-z0-9!#$%&\'*+/=?^_`{|}~][^<]*)(dot[ ]*)(com|org|net|biz|mobi|mobile|0rg|c0m)", "SPAMMING ARE PROHIBITED ", $str); for temporary only but still not good enough. Anybody can help fix it more smoothly. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 17, 2008 Share Posted July 17, 2008 Try this: <pre> <?php $str = preg_replace('/ \S++ (?:\s*|.?) d.?[].?t (?:\s*|.?) (?:c[]m|[]rg|net|biz|mobi(?:le)?) /xi', 'SPAMMING IS PROHIBITED!', $str ); ?> </pre> Quote Link to comment Share on other sites More sharing options...
pandailo Posted July 22, 2008 Author Share Posted July 22, 2008 it works but why preg_replace? any problem with eregi_replace? can you give a little bit explaination on your above php statement. By the way thank you for helping. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 22, 2008 Share Posted July 22, 2008 why preg_replace? any problem with eregi_replace? http://www.phpfreaks.com/forums/index.php/topic,142286.0.html can you give a little bit explaination on your above php statement \S++ ### Capture all non-whitespace possessively (i.e., do not backtrack) (?:\s*|.?) ### Any whitespace or one character (optional) d.?[].?t ### "d", any one character (optional), "o" or "0", any one character (optional), "t" (?:\s*|.?) ### See above. (?:c[]m|[]rg|net|biz|mobi(?:le)?) ### Similar to before, except the grouping is better. 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.