[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Removing whitespace at the beginning and at the end of a string
- From: Choonster TheMage <choonster.2010@...>
- Date: Sat, 15 Jun 2013 03:39:52 +1000
On 15 June 2013 03:25, Choonster TheMage <choonster.2010@gmail.com> wrote:
> On 15 June 2013 03:22, <meino.cramer@gmx.de> wrote:
>> Hi,
>>
>> is there a way to remove leading and trailing whitespace (inluding \n
>> or \r ) from a string with lua without using lpeg or loading a C-Lib
>> for regexp?
>>
>> Thank you very much in advance for any help!
>> Best regards,
>> mcc
>>
>
> somestring = somestring:match("^%s*(.+)%s*$")
Sorry, that plus should be a minus, otherwise the capture includes the
trailing whitespace.
somestring = somestring:match("^%s*(.-)%s*$")