Wikipedia:Reference desk/Archives/Computing/2023 May 14

Computing desk
< May 13 << Apr | May | Jun >> May 15 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 14

edit

Regex help requested

edit

Wasn't sure whether to take this to Wikipedia:Request a query, Wikipedia:Help desk, or here. Landed here.

I'm tryna search wikipedia for articles containing Template:Infobox royalty where the clan_name parameter is non-empty. I used to speak regex twenty years ago, to the point where I once wrote my own parser, but my memory is failing me here. I know my search is supposed to start with hastemplate:"Infobox royalty" insource=/clan_name..., but my efforts to complete the regex in such a way that returns how I'm wanting have led only to results where clan_name is defined but null, and empty sets. Assistance would be appreciated. Shamefully, Folly Mox (talk) 16:38, 14 May 2023 (UTC)[reply]

I haven't use regex in a Wikipedia search. In basic regex, you want something like "clan_name\s*=\s*\w", which demands "clan_name" followed by zero or more spaces followed by "=" followed by zero or more spaces followed by a word character. But, without a reference to the interpreter, it is difficult to know if it uses \s for space and \w for word character. 97.82.165.112 (talk) 12:25, 15 May 2023 (UTC)[reply]
I don't know if \s and \w work in Wikipedia regexes either, but if they don't, you should be able to use something like
clan_name *= *[^ ]
. CodeTalker (talk) 03:59, 17 May 2023 (UTC)[reply]
Have to consider | as well
clan_name *= *[^| ]
Graeme Bartlett (talk) 02:15, 18 May 2023 (UTC)[reply]