(defun make-ci-regex-region (start end)
"Make the string in the region into a case-insensitive regex that will match that string in any case."
(interactive "r")
(if (> (point) (mark)) (exchange-point-and-mark))
(insert-char ?/)
(cl-do () ((>= (point) (mark)))
(when (eq ?w (char-syntax (following-char)))
(insert-char ?\[)
(insert-char (following-char))
(upcase-char 1)
(forward-char)
(insert-char ?\])))
(insert-char ?/))
(defun decode-hex-string (hex-string)
(let ((res nil))
(dotimes (i (/ (length hex-string) 2) (apply #'concat (reverse res)))
(let ((hex-byte (substring hex-string (* 2 i) (* 2 (+ i 1)))))
(push (format "%c" (string-to-number hex-byte 16)) res)))))
(defun hex-decode-region (start end)
(interactive "r")
(replace-region-contents start end
(lambda ()
(decode-hex-string (buffer-string)))))