Appendix B: Parsing a URI Reference with a Regular Expression
The following regular expression can parse a URI reference into its components:
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
12 3 4 5 6 7 8 9
Component Mapping:
$1= scheme:$2= scheme$3= //authority$4= authority$5= path$6= ?query$7= query$8= #fragment$9= fragment
Example: http://www.ics.uci.edu/pub/ietf/uri/#Related
- scheme =
http - authority =
www.ics.uci.edu - path =
/pub/ietf/uri/ - query = (undefined)
- fragment =
Related