Regex for validating url

Rated 4.73/5 based on 961 customer reviews

It looks like Diego's regex here is the best option for correctness. Another great site for testing regex is Chris, you save me ton of time :) I own you a starbuck!

( 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.

Leave a Reply