Regular expression validating url
The only problem with this approach is that it has a few caveats.
The PHP filter_var function has only been available since PHP 5.2.
It is easy to just remove the unwanted parts of the validation to fit different scopes (length, precision) so I will probably add more options like the list of existing TLD (possibly grouped), the list of existing protocols and/or a fall back for a more generic protocol match too. my Java Script URI parsing library does strict URI validation as per RFC 3986.
The second validation block also takes care of excluding IP address terminating with 0 or 255 (non usable network and broadcast addresses of each class C network).
Also, have a look at a free online regular expression tool by Derek Slager. $ For starters, you’ll want to make sure that you set your expression to ignore the case, or capital letters in a URL will cause it to fail.For example if some one types my [email protected] then even though I have typed some garbage immediately after .com, its not catching the error. It seems the Regular Expression Validator does not let you check for an empty field.As I understand it, it doesn't actually run the regular expression validation until there has been something submitted to run the regular expression across.You can use this tool to test your regular expressions if you don’t have a program on your computer to do so. Alternately, convert the URL to lower case before applying this expression.I have spent quite some time trying to find a good online regular expression testing tool, but every one I have found is either too expensive, or full of advertising, so this tool is definitely worth checking out. To review the structure of the expression; the ^ symbol matches the start of the line and the $ symbol matches the end of the line.