I'm trying to create a strict chat filter for those that choose the strict version. I would like to block all URLs except a few whitelisted ones (youtube, prntscr, facebook, etc) to prevent people from sending porn, IP grabbers, virus downloads, etc.
I know I could do this with a few extra lines of code, however is there a way to do this using a regular expression? I would like to have it check if the string contains a URL but the URL is not a whitelisted one (youtube.com for example).
I'm looking to implement this in both Python and PHP, but I only need the regex since I know how to simply use regular expressions in both languages.
Thanks
Edit: to be clear - this is for a strict mode on a chat system. The messages a user sends could be anything from "Hello" to "http://unsafelink.com go there!!"