[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regular expression - replace lower case to upper case

From: Reiner Steib
Subject: Re: Regular expression - replace lower case to upper case
Date: Fri, 01 Nov 2002 20:34:29 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.1 (i586-pc-linux-gnu)

On Fri, Nov 01 2002, Michael Slass wrote:

> Try this:
> (defun upcase-html-tags (buf)
>  (interactive "*bUpcase html tags in buffer: ")
>       (message "upcased %d html tags" counter)))) 

Nice. I changed your function slighly: include closing tags (</foo>),
always use current buffer. Because I prefer lowercase tags, you need
do give a prefix argument, if you want uppercase tags:

M-x rs-html-downcase-or-upcase-tags RET     --> downcase buffer
C-u M-x rs-html-downcase-or-upcase-tags RET --> upcase buffer

(defun rs-html-downcase-or-upcase-tags (&optional upcase)
  "Downcase html-tags in curent buffer.  If given a prefix, upcase tags."
  (interactive "P")
    (goto-char (point-min))
    (let ((counter 0))
      (while (re-search-forward "</?\\(\\w+\\)>" nil t)
         (if upcase 'upcase-region 'downcase-region)
         (match-beginning 1) (match-end 1))
        (setq counter (1+ counter)))
      (message "%scased %d html-tags" (if upcase "up" "down") counter))))

Bye, Reiner.
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW

reply via email to

[Prev in Thread] Current Thread [Next in Thread]