Function: pdf-util-highlight-regexp-in-string

pdf-util-highlight-regexp-in-string is a natively compiled function defined in pdf-util.el.

Signature

(pdf-util-highlight-regexp-in-string REGEXP STRING &optional FACE)

Documentation

Highlight all occurrences of REGEXP in STRING using FACE.

FACE defaults to the match face. Returns the new fontified string.

Source Code

;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-util.el
(defun pdf-util-highlight-regexp-in-string (regexp string &optional face)
  "Highlight all occurrences of REGEXP in STRING using FACE.

FACE defaults to the `match' face.  Returns the new fontified
string."
  (with-temp-buffer
    (save-excursion (insert string))
    (while (and (not (eobp))
                (re-search-forward regexp nil t))
      (if (= (match-beginning 0)
             (match-end 0))
          (forward-char)
        (put-text-property
         (match-beginning 0)
         (point)
         'face (or face 'match))))
    (buffer-string)))