M
M
mstarrr2011-12-02 12:53:59
PHP
mstarrr, 2011-12-02 12:53:59

php regex to get unique domains in a string

I ran into a problem: on a hacked site or just picked up a password, a “left” link to the site of some SEO optimizer appeared. If a virus appeared, there would be a notification right away, and since the link is quite harmless, it hung for about six months and I suspect that it will hang further next time.

I want to check the rest of the site's content for the presence of such external links: that is, I need a regular expression that receives a dump of content tables as input, and a list or array of unique (not previously repeated) domains as output.

In principle, you can omit uniqueness and get at least the entire list of domains. I hope for your help, since Google and my skills in regular seasons have not helped yet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mixailo, 2011-12-02
@mstarrr

(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

s?

L
linux2000, 2011-12-02
@linux2000

On this topic, Google is very helpful.
www.google.com/#sclient=psy-ab&hl=en&source=hp&q=preg_match_all+domain&pbx=1&oq=preg_match_all+domain&aq=f&aqi=&aql=&gs_sm=e&gs_upl=1823l8060l0l9165l25l18l2l4l5l1l315l3539l1.8.7.2l23l0&bav=on.2 , or.r_gc.r_pw .r_cp.,cf.osb&fp=9c035c39c3419f8e&biw=1680&bih=956

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question