[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: On refining regexp by adding exceptions systematically
From: |
Rodney Sparapani |
Subject: |
Re: On refining regexp by adding exceptions systematically |
Date: |
Mon, 07 Oct 2002 09:13:48 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.4.1) Gecko/20020518 Netscape6/6.2.3 |
Sorry, I missed the original post. I wanted the same functionality from
regexps myself. However, after I realized that regexps alone would not
do it, I wrote the following routine in elisp for ESS. Enjoy.
(defun ess-search-except (regexp &optional except backward)
"Search for a regexp, store as match 1, optionally ignore strings that
match exceptions."
(interactive)
(let ((continue t) (exit nil))
(while continue
(if (or (and backward (search-backward-regexp regexp nil t))
(and (not backward) (search-forward-regexp regexp nil
t))) (progn
(setq exit (match-string 1))
(setq continue (and except (string-match except exit)))
(if continue (setq exit nil)))
;else
(setq continue nil)))
exit))
--
Rodney Sparapani Medical College of Wisconsin
Sr. Biostatistician Patient Care & Outcomes Research
rsparapa@mcw.edu http://www.mcw.edu/pcor
Was 'Name That Tune' rigged? WWLD -- What Would Lombardi Do