[lug] XEmacs quoting madness!

David dajo at frii.com
Mon Aug 20 18:15:09 MDT 2001


Well, Tony, you really got me thinking about this regexp stuff.  I do
regexps every now and then and so I decided to write your example
using my lisp library of regexp tools just to see what happened.  Now
I do not expect you to like this, nobody else does; but I thought you
might find it interesting.  For me the advantages are that I do not
have to fight the escaping stuff again (I did it once); and I do not
have to re-learn things that I have forgotten; and the outcome is that
I make far fewer errors.

This is evaluated code from my scratch buffer; yours first.  Normally
I do not put in the comments at the ends of the lines; the theory is
that the function names are descriptive enough.


(concat "^\\\""           ; beginning of line + initial quote
        "\\([^\\\"]+\\)"  ; software bit
        "[\\\",]+"        ; intervening commas and quotes
        "\\([^\\\"]+\\)"  ; description
        ".*$")            ; rest of line.
"^\\\"\\([^\\\"]+\\)[\\\",]+\\([^\\\"]+\\).*$"


(concat
 ;; beginning of line + initial quote
 (bas-regcomp-leading-anchor)                         ; "^"
 (bas-lispify-string  (bas-codestring-quote))         ; "\\\"" see below
 
 ;; software bit
 (bas-regcomp-group-open)                             ; "\\("
 (bas-make-character-set  (list                       ; "[^\\\"]"
                           (bas-regcomp-diy-not)
                           (bas-regcomp-quote)))
 (bas-regcomp-one-or-many)                            ; "+"
 (bas-regcomp-group-close)                            ; "\\)"
 
 ;; intervening commas and quotes
 (bas-make-character-set  (list                       ; "[\\\",]"
                           (bas-regcomp-quote)
                           (bas-codestring-comma)))
 (bas-regcomp-one-or-many)                            ; "+"
 
 ;; description
 (bas-regcomp-group-open)                             ; "\\("
 (bas-make-character-set  (list                       ; "[^\\\"]"
                           (bas-regcomp-diy-not)
                           (bas-regcomp-quote)))
 (bas-regcomp-one-or-many)                            ; "+"
 (bas-regcomp-group-close)                            ; "\\)"
 
 ;; rest of line.
 (bas-regcomp-any-character)                          ; "."
 (bas-regcomp-zero-or-many)                           ; "*"
 (bas-regcomp-trailing-anchor)                        ; "$"
 )
"^\\\"\\([^\\\"]+\\)[\\\",]+\\([^\\\"]+\\).*$"


;;; Note that (bas-regcomp-quote) is defined as
;;; (bas-lispify-string  (bas-codestring-quote)).  Both are used above.

dajo




More information about the LUG mailing list