I want to build a regular expression in c++{MFC} which validates the URL.
The regular expression must satisfy following conditions.
How to check if a url is valid or not duplicate Ask Question 1. This question already has an answer here: How to check whether a string is a valid HTTP URL? 9 answers I am trying to filter out invalid url from valid ones using.NET. I am using Uri.TryCreate method for this. It has the following syntax. How to check if a URL is valid/working (host is reachable) How to check if a URL is valid/working (host is reachable) Author Message; Felix Haa #1 / 2. How to check if a URL is valid/working (host is reachable) As subject says, I'd need to know how to verify that an URL is valid. That means that not only the syntax is correct, but that the.
Valid URL:-http://cu-241.dell-tech.co.in/MyWebSite/ISAPIWEBSITE/Denypage.aspx/http://www.google.comhttp://www.google.co.in
Invalid URL:-
- http://cu-241.dell-tech.co.in/MyWebSite/ISAPIWEBSITE/Denypage.aspx/ = Regx must check & invalid URL as ' character between '/MyWebSite/ISAPIWEBSITE/Denypage.aspx/'
- http://cu-241.dell-tech.co.in//////MyWebSite/ISAPIWEBSITE/Denypage.aspx/ = Regx must check & invalidate URL due to multiple entries of '///////' in url.
- http://news.google.co.in/%5Cnwshp?hl=en&tab=wn = Regex must check & invalidate URL for additional insertion of %5C & %2F character.
How can we develop a generic Regular Expression satisfying above condition.Please, Help us by providing a regular expression that will handle above scenario's in CPP{MFC}
user701960user701960
2 Answers
Have you tried using the RFC 3986 suggestion? If you're capable of using GCC-4.9 then you can go directly with
<regex>
.It states that with
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(?([^#]*))?(#(.*))?
you can get as submatches:For example:
Then:
Ciro CostaCiro Costa
look at http://gskinner.com/RegExr/, there is a community tab on the right where you find contributed regex's. There is a URI category, not sure you'll find exactly what you need but this is a good start
davkadavka