I think you're right on what's the problem. Chopping the varstring creates
a list of characters,
("C" "I" "T" "Y"), and the final list would look like '(@A ("C" "I" "T"
"Y") @B), which does
not match '(@A "C" "I" "T" "Y" @B) above.If you want (match '(@A (chop varstring) @B) description) to match (match '(@A "C" "I" "T" "Y" @B) description) you'll have to add a tilde before chop, like this: (match '(@A ~(chop varstring) @B) description) The tilde is a read macro, and it will splice the result into the list. You can read more about read macros here: http://software-lab.de/doc/ref.html#macro-io That said, do you think you could keep "CITY" intact inside the list, without cutting it into its letters? I mean, would (match '(@A "CITY" @B) description) work for what you want to do? Because if it does, then you can write: (setq varstring "CITY") (match '(@A varstring @B) description) which is much simpler than the first solution I gave. On Mon, Jan 2, 2017 at 10:52 PM, Joe Golden <[email protected]> wrote: > I'm trying to do some simple string matching and find match works nicely > when the string is a literal list of chars like > > (match '(@A "C" "I" "T" "Y" @B) description) > > but I need to match on a variable string stored in varstring which then > needs to get chopped (I think). I'm running into problems with > > (setq varstring "CITY") > (match '(@A (chop varstring) @B) description) > > perhaps the function in the middle of the quote is the problem? Or the > extra list introduced by chop? > > Any guidance appreciated. > -- > Joe Golden > -- > UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe >
