lua-users home
lua-l archive

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


Here's my LPEG search function:


function search(patt)
     return (patt + P(1))^0
end


Apply it to any pattern.





On Tue, Nov 11, 2014 at 7:58 PM,  <meino.cramer@gmx.de> wrote:
> Hi,
>
> (I am no native english speaker...)
>
> I looked (and tried to understand ...) Robertos video about the
> concepts of lpeg/peg on Youtube and I read the lpeg tutorial
> lpeg pages.
>
> But still I am running against an inner wall...years of using regexps
> could not be nullified that fast... ;)
>
> One sentence of Robertos video stick in my head: Lpeg do not search.
>
> How can I recognize the appearance of a certain pattern in a string
> then?
>
> For example:
> mystinrg="CHaskellLispFortranBPCLAssemblerForthLuaSchemePerlCHILLTeXJavaJavascript"
>
> Is it possible to check with LPeg and without missusing it , wheter "Lua"
> is in that string and where (I know, that there are other lpegless methods to
> do that ... thats why this is an example ;) ?
>
> If this not possible or only can be "tricked"...how can LPeg react on
> only partly known input formats?
>
> Or is that a typical question of someone, who is still under the bad
> influence of regexps?
>
>
> Best regards,
> Meino
>
>
>
>
>
>