Regex for validating url
It looks like Diego's regex here is the best option for correctness.
https://mathiasbynens.be/demo/url-regex Another great site for testing regex is Chris, you save me ton of time :) I own you a starbuck!
(https://mathiasbynens.be/demo/url-regex) I have already picked one that best suits my needs.
Feel free to comment if there are any cons of using such regex.vinoth.ree, the said regex may not serve you any good but it may serve someone else.
I should mention that 99.9% of domains will fall into standard form ( handle.domain or )As such, You are definitely more likely to let a user enter a bad URL they did not intend because it validates then to let a uncommon domain actually be used.
As such- a much simpler regex would likely 'make more people happy' than being 100% correct to tech spec.
So here I have better control over the spam and can open the comments again.
This is done to (1) minimize input string length, (2) draw the benefits of a consistent interface, and (3) avoid screwing around with the fragility of url shortening nonsense.
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.
Just to share with you all of my findings and feel free to comment as I'm no expert in this regex so I just use whichever I feel can solve my problem.
After spending hours of research to use regex and even Data:: Validate:: URI, finally I have encounter this website list with lots of regex to check if url is valid or not.