|
Hi
Thanks for all the help guys, I went with the solution local stripped = input:gsub("[\\\"']+", "") I had almost come up with that myself, the mistake I made was with all the pesky escape triple blackslashes I hadnt got that quite correct Regards Geoff > From: dirk.laurie@gmail.com > To: lua-l@lists.lua.org > Subject: Re: Stumped on a string patterns example > > 2012/10/9 Jeff Smith <spammealot1@live.co.uk>: > > > > > I have a string that maybe in any of these forms. I will omit the outer Lua > > string speechmarks for clarity > > > > Fred > > "Fred" > > 'Fred' > > \"Fred\" > > \'Fred\' > > > > I need to strip any speechmark and backslash characters and just return the > > string Fred as a Lua string. The name inside the speechmarks could have > > spaces or numbers in it just to complicate things a bit > > > > pat="(%p*)([%w ]*)(%p*)" > start, name, stop = str:match(pat) > if start~=stop then error "mismatched delimiters" end > > This will of course also allow *Fred* etc. Is that a problem? > |