Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!cs.utexas.edu!uunet!psinntp!news.rlcn.rl.af.mil!lawton
From: lawton@AI.RL.AF.MIL (James Lawton)
Subject: Re: Can you better write this string manipulation function?
Message-ID: <lawton.779376989@ai.rl.af.mil>
Sender: news@news.rlcn.rl.af.mil
Nntp-Posting-Host: armand.ai.rl.af.mil
Organization: Rome Laboratory USAF
References: <34l75h$1sm@engr.orst.edu> <34lfvb$jr7@anaxagoras.ils.nwu.edu>
Date: Mon, 12 Sep 1994 13:36:29 GMT
Lines: 25

;; Recursively, one could do it something like:

(defun remove-curly-brace-comments (str)
  (let (left right)
    (cond ((string-equal str "") str)
	  ((setq left (position #\{ str))
	   (setq right (position #\} str :start left))
	   (concatenate 'string
	       (subseq str 0 left)
	       (remove-curly-brace-comments (subseq str (+ right 1))))
	   )
	  (t str))))

;; Examples:
;;
;;(remove-curly-brace-comments "This is {not} a string")
;;  "this is  a string"
;;(remove-curly-brace-comments "This is {not} a {stupid} string")
;;  "This is  a  string"

--
James H. Lawton            || Disclaimer: The opinions and views
Rome Laboratory            || expressed here are MINE!  They may
Griffiss AFB, NY 13441     || not reflect those of Rome Laboratory,
email: lawton@ai.rl.af.mil || the US Air Force, or most anyone else.
