Title |
Test
Find
URI Validation & Extraction
|
Expression |
^((http|https|ftp):\/\/)?((.*?):(.*?)@)?([a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])((\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])*)(:([0-9]{1,5}))?((\/.*?)(\?(.*?))?(\#(.*))?)?$ |
Description |
Validates and extracts URI components.
Protocol is optional.
Username & Password is optional.
Host regex was taken from Remi Sabourin and follows RFC1035 except that it allows hostnames greater than 253 chars.
Also TLD length is not restriced.
Port number is optional.
Absolute Path is optional, and also extracts the optional querystring and optional anchor reference. |
Matches |
http://john:@www.domain.com:8080/index.html?param=value#Page1 |
Non-Matches |
http://www.domain.com:/ | www-.domain.com |
Author |
Rating:
Not yet rated.
John Bayly
|
Source |
Remi Sabourin |
Your Rating |
|
Title: Mr.
Name: Putinas Piliponis
Date: 12/13/2007 6:03:36 AM
Comment:
Better version of this. in backreference goes preceselly protocol, username, password, hostname and port. As well faster since doesn't use backtracing:
^(?:(http|https|ftp):\/\/)?(?:([^:]+):([^@]+)@)?((?:[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(?:(?:\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])*))(?::([0-9]{1,5}))?((\/.*?)(\?(.*?))?(\#(.*))?)?$
Title: Mr.
Name: Putinas Piliponis
Date: 12/13/2007 5:50:36 AM
Comment:
Better version of this. in backreference goes preceselly protocol, username, password, hostname and port. As well faster since doesn't use backtracing:
^(?:(http|https|ftp):\/\/)?(?:([^:]+):([^@]+)@)?((?:[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(?:(?:\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])*))(?::([0-9]{1,5}))?((\/.*?)(\?(.*?))?(\#(.*))?)?$