Given this regex:
^((https?|ftp):(\/{2}))?(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|(((([a-zA-Z0-9]+)(\.)*?))(\.)([a-z]{2}
|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum){1})
Reformatted for readability:
@"^((https?|ftp):(\/{2}))?" + // http://, https://, ftp:// - Protocol Optional
@"(" + // Begin URL payload format section
@"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" + // IPv4 Address support
@")|("+ // Delimit supported payload types
@"((([a-zA-Z0-9]+)(\.)*?))(\.)([a-z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum){1}" + // FQDNs
@")"; // End URL payload format section
How can I make it fail (i.e. not match) on this "fail" test case?
http://www.google
As I am specifying {1} on the TLD section, I would think it would fail without the extension. Am I wrong?
Edit: These are my PASS conditions:
- "http://www.zi255.com?Req=Post&PID=4",
- "http://www.zi255.com?Req=Post&ID=4",
- "http://www.zi255.com/?Req=Post&PID=4",
- "http://www.zi255.com?Req=Post&PostID=4",
- "http://www.zi255.com/?Req=Post&ID=4"
- "http://www.zi255.com?Req=Post&Post=4",
- "http://www.zi255.com?Req=Post&Entry=4",
- "http://www.zi255.com?PID=4"
- "http://www.zi255.com/Post.aspx?Req=Post&ID=4",
- "http://www.zi255.com/Post.aspx?Req=Post&PID=4",
- "http://www.zi255.com/Post.aspx?Req=Post&Post=4",
- "http://www.zi255.com/Post.aspx?Req=Post&Title=Random%20Post%20Name"
- "http://www.zi255.com/?Req=Post&Title=Random%20Post%20Name",
- "http://www.zi255.com?Req=Post&Title=Random%20Post%20Name",
- "http://www.zi255.com?Req=Post&PostID=4",
- "http://www.zi255.com?Req=Post&Post=4",
- "http://www.zi255.com?Req=Post&Entry=4",
- "http://www.zi255.com?PID=4"
- "http://www.zi255.com",
- "http://www.damnednice.com"
These are my FAIL conditions:
- "http://.com",
- "http://.com/",
- "http:/www.google.com",
- "http:/www.google.com/",
- "http://www.google",
- "http://www.googlecom",
- "http://www.google.c",
- ".com",
- "https://www..."