Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/114999-solved-eregi_replace-certain-words/
Share on other sites

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.

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.

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.?[O0].?t ### "d", any one character (optional), "o" or "0", any one character (optional), "t"

(?:\s*|.?) ### See above.

(?:c[O0]m|[O0]rg|net|biz|mobi(?:le)?) ### Similar to before, except the grouping is better.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.