[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Stumped on a string patterns example
- From: Daurnimator <quae@...>
- Date: Wed, 10 Oct 2012 01:46:40 +1100
On 10 October 2012 01:40, Jeff Smith <spammealot1@live.co.uk> wrote:
> Hi
>
> I am not great at figuring out these Lua patterns, here is a litle problem
> someone might be able to help me with please ?
>
> 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
>
> Whats the most concise Lua way of doing this ?
>
> Thanks for any code snippets.
>
> Regards Geoff
>
First instinct should be gsub. Try:
mystr:gsub("[\\\"']","")