Xah Talk Show 2022-11-25 Emacs Lisp Coding, $sigil in Lisp, Clojure, Regex Alt Syntax

Xah Talk Show 2022-11-25 Emacs Lisp Coding, $sigil in Lisp, Clojure, Regex Alt Syntax
(defun xah-html-change-local-link-in-string (TextBlock CurrentDir TargetDir)
  "Return a string, that is TextBlock HTML, with all local links in it changed, from CurrentDir, to TargetDir.
Version 2022-11-25"
  (interactive)
  (let ($hrefVal $fullpath $newRelPath $p1 $p2)
    ;; go thru the input string, find each and every link, that is, tag a.
    ;; if it is a local link, change it so it is correct with respect to
    ;; TargetDir
    (with-temp-buffer
      (insert TextBlock)
      (goto-char (point-min))
      (while (re-search-forward "<a href=\"\\([^\"]+\\)\">" nil t)
        (progn
          ;; <a href="mouse_history.html">Mouse History</a>
          (setq $hrefVal (match-string 1))
          (setq $p1 (match-beginning 1))
          (setq $p2 (match-end 1))
          ;; check if the link is local link
          (if (string-match "^https?://" $hrefVal)
              nil
            (progn
              ;; get full path
              (setq $fullpath (expand-file-name $hrefVal CurrentDir))
              (setq $newRelPath (file-relative-name $fullpath TargetDir))
              (delete-region $p1 $p2)
              (goto-char $p1)
              (insert $newRelPath)))))
      (buffer-substring (point-min) (point-max)))))

(xah-html-change-local-link-in-string
"<ul>
<li><a href=\"mouse_history.html\">Mouse History</a></li>
<li><a href=\"apple_mouse.html\">Apple Mouse</a></li>
<li><a href=\"neogeo.html\">SNK NeoGeo arcade system, stripper ad</a></li>
<li>🆕 <a href=\"logitech_mouseman.html\">Logitech Mouseman, Year 1991</a></li>
<li>🆕 <a href=\"microsoft_ps2_mouse.html\">Microsoft PS/2 Mouse, Year 1991</a></li>
</ul>"

"c:/Users/xah/web/xahlee_info/kbd/"
"c:/Users/xah/web/xahlee_info/"
)

;; "<ul>
;; <li><a href=\"kbd/mouse_history.html\">Mouse History</a></li>
;; <li><a href=\"kbd/apple_mouse.html\">Apple Mouse</a></li>
;; <li><a href=\"kbd/neogeo.html\">SNK NeoGeo arcade system, stripper ad</a></li>
;; <li>🆕 <a href=\"kbd/logitech_mouseman.html\">Logitech Mouseman, Year 1991</a></li>
;; <li>🆕 <a href=\"kbd/microsoft_ps2_mouse.html\">Microsoft PS/2 Mouse, Year 1991</a></li>
;; </ul>"