u_ser__
u_ser__

Reputation: 45

Regex - filter websites and IPs

What regex can detect the presence of any IP address or URL in a string. It should be able to detect people trying to obviously avoid the filter: Examples:

154.43.45.345

website.com

website . com

website dot com

website?@#[]?.,<>.com

etc

Thanks!

Upvotes: 0

Views: 102

Answers (1)

C.B.
C.B.

Reputation: 8336

The IP Regex is very straightforward, as it's structure is constant

(\d{1,4}\.){3}\d{1,4}

For websites, I would need more detailed info, but the general idea is like

.+((\.|dot).+)*(\.|dot)\s*(com|net|org|gov|uk...)

or, extremely basic

.*(\.|dot).*(com|net|org|gov|uk...)

Upvotes: 1

Related Questions