lua-users home
lua-l archive

Re: Removing whitespace at the beginning and at the end of a string

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Choonster TheMage <choonster.2010@gmail.com> [13-06-14 19:28]:
> 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*$")
> 
I tried this, but it seems that (.*) also eats the trailing spaces.
The resulting string still contains " "s at the end...
Best regards,
mcc

AltStyle によって変換されたページ (->オリジナル) /