Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want regex which validate entered url.
My regex is not verify only three W (WWW)
It also accept www.com which is incorrect.
Please help me to fix this.

What I have tried:

ValidationExpression="^((http|ftp|https)://)?([\w-]+\.)+[\w]+(/[\w- ./?]*)?$"
Posted
Updated 18-Apr-18 4:16am

Look at the following:
[^]
May find something there you like
 
Share this answer
 
Google gives thousand of answers depending on what you want to match exactly, without example of what should match and what shouldn't, it is complicated to find the regex that fit your needs.
Try:
^((https?:[/][/])?(\w+[.])+com|((https?:[/][/])?(\w+[.])+com[/]|[.][/])?\w+([/]\w+)*([/]|[.]html|[.]php|[.]gif|[.]jpg|[.]png)?)$

from REGEX for validating URL[^]

Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900