User:Aldyron/Sandbox/Template List of monsters in habitat

Chaotic notes
The namespace constraint is currently redundant. Keep it if querying time is lower with it.

Using Missing in Action as our work-in-progress target quest gives no results. Using The Grotto gives 1 result. It's the system-wide limit of 500 again: when querying the whole alphabetic-sorted list of monsters (WASLOM), no monster from Missing in Action appears in the first 500 (the first one is Dog, beyond the 500th in the WASLOM, currently Darkfang Hunter), while one monster from The Grotto is in the first 500 (Aging Sahuagin Warrior). That is, instead of querying everything and then limiting at 500, it queries at most 500 and then checks for matches. It will never be suitable this way. Showstopper.

Using Vault of Night yields a few results, useful for mixed-formats wrangling.

Eureka. Using linksto severely limits page selections to the few monsters that actually link to the quest. Less CPU load, less storage load, less time. Drawback: doesn't take redirects into account. Oh, well, I wanted to correct every link in every monster page anyway. :-)))

Must check that the link to the quest actually is in the habitat parameter, otherwise you get false positives (e.g.: Velah cites Vault of Night in the description parameter, but the monster is not in the quest).

Linked. Must provide for empty field values, otherwise we get. Employ phantom template. Update: done.

Staging area

 * |includematch = /the grotto/i
 * It works, but we need a much stricter check.
 * |includematch = /\x7c\s*habitat\s*=\s*[^\x7c]*Missing in Action/i
 * |includematch =    /     \x7c     \s*     habitat     \s*     =     \s*     [^\x7c]*     Missing in Action     /     i  (rewritten for clarity)
 * (slash) opens the regex
 * matches the pipe character, |
 * matches whitespace/tabs/newlines in any quantity, including zero quantity
 * matches any character except | in any quantity, including zero quantity
 * (slash) closes the regex
 * at the end is a PCRE Pattern Modifier for caseless matching (though I personally prefer caseful matching)

Coding
(see source)