Escaping backslashes in append operation for use in regex

Started by maq, August 04, 2005, 08:52:40 AM

Previous topic - Next topic

maq

I have a small issue getting a regex to work the way I want it to. I set a string to the following:
(set 'command-line "woot -r 45 -w 46")
And then I want to alternate through the command line options by comparing against a list of flags that I'm looking for. Say:
(set 'opts '("r" "w"))
So I want to do the following:
(dolist (o opts)
(if (find (append "-" o "s*(w*)(s*-|$)") command-line 0)
(do-something with $1)
)
)

However I don't get a match because the append takes out the "" before the s & w. when I try to escape the "" I get "\s" or "\w", which also does not match.  So my question is, how can I escape a backlash for an append to output only a singular ""?



Thanks in advance,

--maq

Sammo

#1
try



(append "-" o {s*(w*)(s*-|$)})



in which I replaced the double-quote string delimiters with left and right brace string delimiters,



instead of



(append "-" o "s*(w*)(s*-|$)")



Using braces instead of double-quotes removes the need to treat the backslash characters with special care.



-- sam

maq

#2
Thanks Sammo. That does the trick.



--maq