Your Regex is badly shaped. You can decompose it in three parts;
- \b(?:(?:https?|ftp)://|www.) (Starts with http or https or such)
- [-a-z0-9+&@#/%?=~_|!:,.;]* (Any character)
- [-a-z0-9+&@#/%=~_|] (Any character)
Your expression reads "Anything starting with {1}, followed by {2} that can appear from 0 to many times, followed by {3} (which is anything)"
So, well, as {2} is optional due the * modifier, it finally reads like "Anything starting with http:// and followed by anything matches
First I would recommend using Rubular to check your Regex when you build them, it's a REALLY helpful website http://rubular.com . If you would want to fix the regex you should at least require some dots in the middle.
Second, for this particular case you should check this response by Gordon in
Best way to check if a URL is valid
Which snipped from there the response is:
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
die('Not a valid URL');
}