Wikipedia talk:Lua
![]() | To help centralize discussions and keep related topics together, all Wikipedia:Lua subpages' talk pages and Help talk:Lua redirect here. |
![]() | The content of Wikipedia:Lua/Requests was merged into Wikipedia talk:Lua on 5 February 2016. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
![]() | Wikipedia:Lua/To do was nominated for deletion on 21 May 2015. The result of the discussion was keep. |
This page has archives. Sections older than 90 days may be auto-archived by ClueBot III if there are more than 1. |
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)
- 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)
- Agreed. Module:Random could do the same thing trivially. * Pppery * it has begun... 22:32, 7 July 2025 (UTC)
- 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 • {C•X}) 16:51, 10 July 2025 (UTC)
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)
- 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)- 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")
– returnsSep
mw.language.getContentLanguage():formatDate ("F", "17 September 2025")
– returnsSeptember
mw.language.getContentLanguage():formatDate ("m", "17 September 2025")
– returns09
mw.language.getContentLanguage():formatDate ("n", "17 September 2025")
– returns9
- —Trappist the monk (talk) 18:57, 17 September 2025 (UTC)
- Thanks!!! —Zackmann (Talk to me/What I been doing) 19:00, 17 September 2025 (UTC)
- What are you actually trying to do? Maybe {{extract}}. Johnuniq (talk) 04:24, 18 September 2025 (UTC)
- Thanks!!! —Zackmann (Talk to me/What I been doing) 19:00, 17 September 2025 (UTC)
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)
- That will be really useful. Thanks for the tip — Martin (MSGJ · talk) 08:13, 30 September 2025 (UTC)