* [NTG-context] regular expression as lua pattern @ 2024-05-28 16:12 Pablo Rodriguez via ntg-context 2024-05-28 16:25 ` [NTG-context] " Tomáš Hála 0 siblings, 1 reply; 7+ messages in thread From: Pablo Rodriguez via ntg-context @ 2024-05-28 16:12 UTC (permalink / raw) To: ConTeXt users; +Cc: Pablo Rodriguez 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 2024-05-28 16:12 [NTG-context] regular expression as lua pattern Pablo Rodriguez via ntg-context @ 2024-05-28 16:25 ` Tomáš Hála 2024-05-28 16:40 ` Pablo Rodriguez via ntg-context 2024-05-28 18:06 ` Hans Hagen 0 siblings, 2 replies; 7+ messages in thread From: Tomáš Hála @ 2024-05-28 16:25 UTC (permalink / raw) To: Pablo Rodriguez via ntg-context; +Cc: Pablo Rodriguez Hi Pablo, unfortunately, that it is not possible: http://lua-users.org/wiki/PatternsTutorial, section Limitations. The best, Tomáš 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 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 1 sibling, 0 replies; 7+ messages in thread From: Pablo Rodriguez via ntg-context @ 2024-05-28 16:40 UTC (permalink / raw) To: ntg-context; +Cc: Pablo Rodriguez On 5/28/24 18:25, Tomáš Hála wrote: > Hi Pablo, > > unfortunately, that it is not possible: > > http://lua-users.org/wiki/PatternsTutorial, section Limitations. Many thanks for your reply, Tomáš. It is clear to me now. 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 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 2024-05-29 11:00 ` Henning Hraban Ramm 2024-05-29 15:14 ` Pablo Rodriguez via ntg-context 1 sibling, 2 replies; 7+ messages in thread From: Hans Hagen @ 2024-05-28 18:06 UTC (permalink / raw) To: ntg-context 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 2024-05-28 18:06 ` Hans Hagen @ 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 1 sibling, 1 reply; 7+ messages in thread From: Henning Hraban Ramm @ 2024-05-29 11:00 UTC (permalink / raw) To: ntg-context Am 28.05.24 um 20:06 schrieb Hans Hagen: > 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 See also Taco’s introduction to LPEG in https://articles.contextgarden.net/journal/2019/77-98.pdf Hraban ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 2024-05-29 11:00 ` Henning Hraban Ramm @ 2024-05-29 15:16 ` Pablo Rodriguez via ntg-context 0 siblings, 0 replies; 7+ messages in thread From: Pablo Rodriguez via ntg-context @ 2024-05-29 15:16 UTC (permalink / raw) To: ntg-context; +Cc: Pablo Rodriguez On 5/29/24 13:00, Henning Hraban Ramm wrote: > [...] > See also Taco’s introduction to LPEG in > https://articles.contextgarden.net/journal/2019/77-98.pdf Many thanks for the reference, Hraban. I need to start digesting that to learn about LPEG. 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* [NTG-context] Re: regular expression as lua pattern 2024-05-28 18:06 ` Hans Hagen 2024-05-29 11:00 ` Henning Hraban Ramm @ 2024-05-29 15:14 ` Pablo Rodriguez via ntg-context 1 sibling, 0 replies; 7+ messages in thread From: Pablo Rodriguez via ntg-context @ 2024-05-29 15:14 UTC (permalink / raw) To: ntg-context; +Cc: Pablo Rodriguez On 5/28/24 20:06, Hans Hagen wrote: > 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 Many thanks for your reply, Hans. I will have to study it becasue LPEGs is new stuff for me. 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-29 15:19 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-05-28 16:12 [NTG-context] regular expression as lua pattern 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 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
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).