Return to Snippet

Revision: 6923
at November 23, 2013 07:51 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$7$9");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$2$7?$11#$12 or $1://$5:$6$7?$11#$12
//  - ftp as $1://$2$7 or $1://$4@$5:$6$7
//  - mailto as $1:$9?$11
//- groups are as follows:
//  1   == scheme
//  2   == authority
//  4   == userinfo
//  5   == host (loose check to allow for IPv6 addresses)
//  6   == port
//  7,9 == path (7 if it has an authority, 9 if it doesn't)
//  11   == query
//  12   == fragment

var regexUri = /^([a-z][a-z0-9+.-]*):(?:\/\/((?:(?=((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*))(\3)@)?(?=(\[[0-9A-F:.]{2,}\]|(?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*))\5(?::(?=(\d*))\6)?)(\/(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\8)?|(\/?(?!\/)(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\10)?)(?:\?(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\11)?(?:#(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\12)?$/i;
/*composed as follows:
	^
	([a-z][a-z0-9+.-]*):									#1 scheme
	(?:
		\/\/										it has an authority:
		
		(										#2 authority
			(?:(?=((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*))(\3)@)?		#4 userinfo
			(?=(\[[0-9A-F:.]{2,}\]|(?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*))\5	#5 host (loose check to allow for IPv6 addresses)
			(?::(?=(\d*))\6)?							#6 port
		)
		
		(\/(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\8)?			#7 path
		
		|										it doesn't have an authority:
		
		(\/?(?!\/)(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\10)?		#9 path
	)
	(?:
		\?(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\11			#11 query string
	)?
	(?:
		#(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\12			#12 fragment
	)?
	$
*/

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6922
at November 23, 2013 07:38 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$2$7?$11#$12 or $1://$5:$6$7?$11#$12
//  - ftp as $1://$2$7 or $1://$4@$5:$6$7
//  - mailto as $1:$9?$11
//- groups are as follows:
//  1   == scheme
//  2   == authority
//  4   == userinfo
//  5   == host (loose check to allow for IPv6 addresses)
//  6   == port
//  7,9 == path (7 if it has an authority, 9 if it doesn't)
//  11   == query
//  12   == fragment

var regexUri = /^([a-z][a-z0-9+.-]*):(?:\/\/((?:(?=((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*))(\3)@)?(?=(\[[0-9A-F:.]{2,}\]|(?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*))\5(?::(?=(\d*))\6)?)(\/(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\8)?|(\/?(?!\/)(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\10)?)(?:\?(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\11)?(?:#(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\12)?$/i;
/*composed as follows:
	^
	([a-z][a-z0-9+.-]*):									#1 scheme
	(?:
		\/\/										it has an authority:
		
		(										#2 authority
			(?:(?=((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*))(\3)@)?		#4 userinfo
			(?=(\[[0-9A-F:.]{2,}\]|(?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*))\5	#5 host (loose check to allow for IPv6 addresses)
			(?::(?=(\d*))\6)?							#6 port
		)
		
		(\/(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\8)?			#7 path
		
		|										it doesn't have an authority:
		
		(\/?(?!\/)(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*))\10)?		#9 path
	)
	(?:
		\?(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\11			#11 query string
	)?
	(?:
		#(?=((?:[a-z0-9-._~!$&'()*+,;=:@\/?]|%[0-9A-F]{2})*))\12			#12 fragment
	)?
	$
*/

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6921
at July 9, 2008 13:01 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$7#$8
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $1:$6?$7
//- groups are as follows:
//  1   == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,6 == path (5 if it has an authority, 6 if it doesn't)
//  7   == query
//  8   == fragment

var regexUri = /^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i;
/*composed as follows:
	^
	([a-z0-9+.-]+):							#scheme
	(?:
		//							#it has an authority:
		(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?	#userinfo
		((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)		#host
		(?::(\d*))?						#port
		(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?	#path
		|
									#it doesn't have an authority:
		(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?	#path
	)
	(?:
		\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)	#query string
	)?
	(?:
		#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)	#fragment
	)?
	$
*/

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6920
at July 9, 2008 12:59 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$7#$8
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $1:$6?$7
//- groups are as follows:
//  1   == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,6 == path (5 if it has an authority, 6 if it doesn't)
//  7   == query
//  8   == fragment

var regexUri = /^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i;
/*composed as follows:
	^
	([a-z0-9+.-]+):											#scheme
	(?:
		//													#it has an authority:
		(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?	#userinfo
		((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)			#host
		(?::(\d*))?											#port
		(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?	#path
		|
															#it doesn't have an authority:
		(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?	#path
	)
	(?:
		\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)	#query string
	)?
	(?:
		#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)	#fragment
	)?
	$
*/

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6919
at July 9, 2008 12:55 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$7#$8
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $1:$6?$7
//- groups are as follows:
//  1   == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,6 == path (5 if it has an authority, 6 if it doesn't)
//  7   == query
//  8   == fragment

var regexUri = /^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i;
/*composed as follows:
	^
	([a-z0-9+.-]+):		#scheme
	(?:
		//		#it has an authority
		(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?		#userinfo
		((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)		#host
		(?::(\d*))?		#port
		(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?		#path
		|
		#it doesn't have an authority
		(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?		#path
	)
	(?:
		\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)		#query string
	)?
	(?:
		\#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*)		#fragment
	)?
	$
*/

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6918
at July 9, 2008 12:53 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$7#$8
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $1:$6?$7
//- groups are as follows:
//  1   == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,6 == path (5 if it has an authority, 6 if it doesn't)
//  7   == query
//  8   == fragment

var regexUri = /^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6917
at July 9, 2008 12:47 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the path:
//  path = uri.replace(regexUri, "$5$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$7#$8
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $1:$6?$7
//- groups are as follows:
//  1   == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,6 == path (5 if it has an authority, 6 if it doesn't)
//  7   == query
//  8   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path (5 if it has an authority, 7 if it doesn't)
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6916
at June 30, 2008 10:00 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regexUri, "$1$6");

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6915
at June 30, 2008 08:49 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regex, "$1$6")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6914
at June 25, 2008 08:56 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regex, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6913
at June 24, 2008 16:29 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regex, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i;

Revision: 6912
at June 24, 2008 16:29 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regex, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

var regexUri = /^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

var regexUriDelim = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

var regexUrl = /^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

var regexMailto = /^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

Revision: 6911
at June 24, 2008 16:27 by wizard04


Updated Code
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = uri.replace(regex, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

/^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

/^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

/^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

/^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

Revision: 6910
at June 24, 2008 16:25 by wizard04


Updated Code
//These should all be case-insensitive
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = str.replace(/^(...):.../i, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

/^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

/^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

/^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

/^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$/i

Revision: 6909
at June 24, 2008 16:24 by wizard04


Updated Code
//These should all be case-insensitive
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = str.replace(/^(...):.../i, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

Revision: 6908
at June 24, 2008 16:20 by wizard04


Initial Code
//These should all be case-insensitive
//replace() can be used to parse the URI. For example, to get the scheme:
//  scheme = str.replace(/^(...):.../i, "$1")

//****************************************************//
//***************** Validate a URI *******************//
//****************************************************//
//- The different parts are kept in their own groups and can be recombined
//  depending on the scheme:
//  - http as $1://$3:$4$5?$8#$9
//  - ftp as $1://$2@$3:$4$5
//  - mailto as $6:$7$5?$8
//- groups are as follows:
//  1,6 == scheme
//  2   == userinfo
//  3   == host (does not include IPv6 nor IPvFuture addresses as valid)
//  4   == port
//  5,7 == path
//  8   == query
//  9   == fragment

^(?:([a-z0-9+.-]+):\/\/(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+):(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

//****************************************************//
//** Validate a URI (includes delimiters in groups) **//
//****************************************************//
//- The different parts--along with their delimiters--are kept in their own
//  groups and can be recombined as $1$6$2$3$4$5$7$8$9
//- groups are as follows:
//  1,6 == scheme:// or scheme:
//  2   == userinfo@
//  3   == host (does not include IPv6 nor IPvFuture addresses as valid)
//  4   == :port
//  5,7 == path
//  8   == ?query
//  9   == #fragment

^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$

//****************************************************//
//***************** Validate a URL *******************//
//****************************************************//
//Validates a URI with an http or https scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1://$2:$3$4?$5#$6
//- Does not validate the host portion (domain); just makes sure the string
//  consists of valid characters (does not include IPv6 nor IPvFuture
//  addresses as valid).

^(https?):\/\/((?:[a-z0-9.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

//****************************************************//
//**************** Validate a Mailto *****************//
//****************************************************//
//Validates a URI with a mailto scheme.
//- The different parts are kept in their own groups and can be recombined as
//  $1:$2?$3#$4
//- Does not validate the email addresses themselves.

^(mailto):((?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+)?(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*))?$

Initial URL

                                

Initial Description
(Supported by JavaScript, maybe other languages)

Initial Title
Regular Expressions For URI Validation/Parsing

Initial Tags
regex, email, url, javascript, validation

Initial Language
Regular Expression