Jump to content

Wikipedia talk:Lua

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Query

[edit]

Hello, I'm hoping I'm posting in the right place. A very new editor just created Module:RandomWikiverse and I'm not sure if it's valid or just some sort of experiment because I know nothing about modules. Can someone who does know something review this page? Thank you, in advance, for your help. Liz Read! Talk! 22:23, 7 July 2025 (UTC)[reply]

Looks like it returns a randomly selected phrase from its list of phrases but seems otherwise pointless
{{#invoke:RandomWikiverse|random}} → Rise and Fall of Emperor Quack (refresh this page to get another phrase)
Nothing in it seems valuable to me so can probably be deleted.
Trappist the monk (talk) 22:31, 7 July 2025 (UTC)[reply]
Agreed. Module:Random could do the same thing trivially. * Pppery * it has begun... 22:32, 7 July 2025 (UTC)[reply]
It was created on 28th June, and remains unused. Editor hasn't edited since. Looks like a test that has been completed. It should be deleted or moved under Module:Sandbox. CX Zoom[he/him] (let's talk • {CX}) 16:51, 10 July 2025 (UTC)[reply]

Regex help

[edit]

Any LUA Regex experts who might be able to help me? Trying to write a regex with an or statement in it but my understanding is that LUA doesn’t support or statements in their regexes. So for example if I’m trying to detect a month in a date I would normally do something like:

\d+\s*(Jan|January|Feb|February|…)\s*\d{4}

How can I achieve the same result with a regex in LUA? —Zackmann (Talk to me/What I been doing) 18:36, 17 September 2025 (UTC)[reply]

The first idea that comes to my mind is just using a regular (%a+) catch and then manually checking the content of the group in lua code to see if it matches a known month, since lua regex is far more simplistic than standard regexes. Aidan9382 (talk) 18:44, 17 September 2025 (UTC)[reply]
As did I:
string.match ("17 September 2025", "%d+%s*(%a+)%s*%d%d%d%d") – validate the returned value as a next step
Or one of these:
mw.language.getContentLanguage():formatDate ("M", "17 September 2025") – returns Sep
mw.language.getContentLanguage():formatDate ("F", "17 September 2025") – returns September
mw.language.getContentLanguage():formatDate ("m", "17 September 2025") – returns 09
mw.language.getContentLanguage():formatDate ("n", "17 September 2025") – returns 9
Trappist the monk (talk) 18:57, 17 September 2025 (UTC)[reply]
Thanks!!! —Zackmann (Talk to me/What I been doing) 19:00, 17 September 2025 (UTC)[reply]
What are you actually trying to do? Maybe {{extract}}. Johnuniq (talk) 04:24, 18 September 2025 (UTC)[reply]

Enhanced testing for page existence

[edit]

From Wikipedia:Village pump (technical)#Tech News: 2025-40:

Lua modules will be able to use the mw.title.newBatch function to look up the existence of up to 25 pages at once, in a way that only increases the expensive function count once. See mw:Extension:Scribunto/Lua reference manual#mw.title.newBatch. Johnuniq (talk) 00:04, 30 September 2025 (UTC)[reply]

That will be really useful. Thanks for the tip — Martin (MSGJ · talk) 08:13, 30 September 2025 (UTC)[reply]