xah talk show 2022-07-22 emacs lisp, parse url, regex, trigram, hexagram

(defun xparseURL (xurl)
  "parse xurl, return a list of parts
version 2022-07-22"
  (interactive)
  (let (xprotocol xhost xport xresourcePath xfrag)
    ;; "http://www.example.com:80/a/b/c?x=1&y=2#frag"
    (string-match "^\\([a-zA-Z0-9]+\\)://\\([.a-zA-Z0-9]+\\):\\([0-9]+\\)/\\([/%a-zA-Z0-9]+\\)\\?\\([&%=a-zA-Z0-9]+\\)#\\([.a-zA-Z0-9]+\\)" xurl)
    (setq xprotocol (match-string 1 xurl))
    (setq xhost (match-string 2 xurl))
    (setq xport (match-string 3 xurl))
    (setq xresourcePath (match-string 4 xurl))
    (setq xfrag (match-string 5 xurl))
    (list xprotocol xhost xport xresourcePath xfrag)))

(xparseURL "http://www.example.com:80/a/b/c?x=1&y=2#frag")
(require 'url-parse)
(url-generic-parse-url "http://www.example.com:80/a/b/c?x=1&y=2#frag")