public String asRegEx() {

		StringBuilder sb = new StringBuilder().append("^")
				.append(pattern(scheme, SCHEME_REGEX, "(%s):"))
				.append(pattern(host, HOST_REGEX, "//(%s)"));
		if (host == null || host.pattern().length() > 0) {
			sb.append(port == null ? PORT_REGEX : ((port < 0) ? ""
					: (":" + port)));
		}

		if (path != null && path.pattern().startsWith("/")) {
			sb.append(pattern(path, PATH_REGEX, "((%s))"));
		} else {
			sb.append(pattern(path, PATH_REGEX, "(/?(%s))"));
		}
		sb.append(pattern(fragment, FRAGMENT_REGEX, "(#(%s))"));
		return sb.append("$").toString();
	}