Jump to content

Wikipedia talk:AutoWikiBrowser/Regular expression

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

Query help

[edit]

I'm trying to put together a query that'll search for all pages that have this code:

<noinclude>
{{collapsible option}}
[[Category:BLAHBLAHBLAH navigational boxes]]
</noinclude>

I tried this, but it returned no results, and on some testing, it seems to be struggling with the newline character.

insource:/\<noinclude\>\n\{\{collapsible\soption}}\n\[\[Category:.*navigational boxes\]\]\n\</noinclude\>/

Any idea what I'm doing wrong? {{u|Sdkb}}talk 20:57, 1 August 2023 (UTC)[reply]

@Sdkb: Elastic Search as used in Cirrus has an unusual and limited regular expression syntax.[1] In particular, it doesn't support either \n or \s. Also, the / in /noinclude needs to be escaped as \/. On the bright side, "." does match a newline. You could try something like this. You may get more results by adding <space>* in a few more places. Certes (talk) 23:23, 1 August 2023 (UTC)[reply]
@Sdkb: A noinclude tag may enclose multiple categories. Because ".*" matches newlines, the search above checks for the last (and perhaps only) category being navboxes. To limit the query to noinclude tags which enclose only a single category, change the existing ".*" to "[^\]]*". (Unlike most regexp flavours, Elastic requires ] to be escaped even at the start of [].) Alternatively, to also find pages where other categories appear after navboxes, change the last "." to ".*" instead. Certes (talk) 10:29, 2 August 2023 (UTC)[reply]
Much thanks! The latter is what I'm looking for, so I adopted that at the BRFA. Cheers, {{u|Sdkb}}talk 16:09, 2 August 2023 (UTC)[reply]