lua-users home
lua-l archive

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

> Gavin Wraith wrote:

> > Markus Huber wrote:

> > How can I match all possible EndOfLines in strfind() with a Lua pattern?

> > EndOfLine is  \n\r
> >           or  \r\n
> >           or  \n
> >           or  \r

> >          but  \n\n  are two EndOfLines with an empty string between
> >         also  \r\r

> Are you sure you need to? It is very rare to find different sorts of
> EndOfLines in the same file.

Yes I need it. The function receives data (not files) "written" from
different machines and programms.

> Tom Wrensch wrote:

> I don't think you can do this directly with strfind. The pattern
> matcher built into Lua cannot handle disjunctions of multicharacter
> 'tokens'.

Then I will implement a enhanced strfind() to handle disjunctions of
multicharacter 'tokens' to accept optional an table instead of a single
string search pattern:


Then a standard strfind() call with a single string is - besides the
type check - as fast as ever. And the example above needs internal four
strfind() runs and returns the leftmost result.

Any other suggestions? Has anyone done this before? Do you see problems?

Thank you for your help.