help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Regular expression - replace lower case to upper case


From: Michael Slass
Subject: Re: Regular expression - replace lower case to upper case
Date: Fri, 01 Nov 2002 02:32:32 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"Rod Farmer" <raf@cs.mu.oz.au> writes:

>Hi,
>    I've been looking through the manuals and can't seem to find how to
>replace all occurences of HTML tags in lower case, ie <body> with upper case
><BODY> as seems to be the W3C standards for 4.01
>
>I was going to use M-x % regexp RET string RET but what I really want is
>something like the s/foo/bar/g where
>bar can actually be a reference back to the string that has been
>matched.....
>
>
>thanks heaps
>
>
>Rod
>
>

Try this:

(defun upcase-html-tags (buf)
 (interactive "*bUpcase html tags in buffer: ")
  (save-excursion
    (set-buffer buf)
    (goto-char (point-min))
    (let ((counter 0))
      (while (re-search-forward "<\\(\\w+\\)>" nil t)
        (upcase-region (match-beginning 1) (match-end 1))
        (setq counter (1+ counter)))
      (message "upcased %d html tags" counter)))) 

-- 
Mike Slass


reply via email to

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