ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: regular expression as lua pattern
Date: Tue, 28 May 2024 20:06:07 +0200	[thread overview]
Message-ID: <9c8e8aa9-faf1-4dc2-b476-32ba2dfc6140@xs4all.nl> (raw)
In-Reply-To: <20240528162551.GA31358@thala.cz>

On 5/28/2024 6:25 PM, Tomáš Hála wrote:
> Hi Pablo,
> 
> unfortunately, that it is not possible:
> 
> http://lua-users.org/wiki/PatternsTutorial, section Limitations.

\starttext
	\startTEXpage[pagestate=start, offset=1em]
         \startluacode
             local pat = (lpeg.Cmt(lpeg.P("this") + lpeg.P("that"), 
function(str,_,s)
                 context(s)
                 return #str
             end) + lpeg.P(1))^1
             lpeg.match(pat,"how about this being that")

             local pat = (lpeg.Cmt(lpeg.oneof({ "this", "that" }), 
function(str,_,s)
                 context(s)
                 return #str
             end) + lpeg.P(1))^1
             lpeg.match(pat,"how about this being that")
         \stopluacode
	\stopTEXpage
\stoptext


> On Tue, May 28, 2024 at 06:12:51PM +0200, Pablo Rodriguez via ntg-context wrote:
>> Dear list,
>>
>> I have the following sample:
>>
>> 	\starttext
>> 	\startTEXpage[pagestate=start, offset=1em]
>> 	\startluacode
>> 		local str = "this is that"
>> 		context(str:match("(this|these)"))
>> 	\stopluacode
>> 	\stopTEXpage
>> 	\stoptext
>>
>> In short, I would like to know whether it is possible to have the
>> regular expression (this|these) as a Lua pattern.
>>
>> I mean, I need complete strings and I haven’t found the way to do it.
>>
>> Many thanks for your help,
>>
>> Pablo
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
>> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
>> archive  : https://github.com/contextgarden/context
>> wiki     : https://wiki.contextgarden.net
>> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki     : https://wiki.contextgarden.net
> ___________________________________________________________________________________

-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2024-05-28 18:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 16:12 [NTG-context] " Pablo Rodriguez via ntg-context
2024-05-28 16:25 ` [NTG-context] " Tomáš Hála
2024-05-28 16:40   ` Pablo Rodriguez via ntg-context
2024-05-28 18:06   ` Hans Hagen [this message]
2024-05-29 11:00     ` Henning Hraban Ramm
2024-05-29 15:16       ` Pablo Rodriguez via ntg-context
2024-05-29 15:14     ` Pablo Rodriguez via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9c8e8aa9-faf1-4dc2-b476-32ba2dfc6140@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).