Skip to content

Regex Magic for Lorebook Keys

Marcel Wiechmann edited this page Jun 7, 2022 · 4 revisions

Important to note: Regular keys are case-insensitive, but regex keys are not. Flags are now supported so you can just add the i flag to make regex keys case-insensitive /giraffe/i

  • Also note the tutorial on the NAI wiki
  • Using placeholder with regex (Yaflow): you need the $ before regex too so: $/${name}/
  • Regex AND pattern 1 (Valahraban): Matches a paragraph with the 3 (or less, or more) words in any order. /^(?=.*word1)(?=.*word2)(?=.*word3).*$/
  • Regex AND pattern 2 (ght901): If Name 1 and Name 2 are within 6 words of each other, then it'll activate the key. /\b(NAME 1|NAME 2)(?:\W+\w+){1,6}?\W+(?!\1)(NAME 1|NAME 2)\b/
  • Regex NOT pattern 1 (Valahraban): Does not match a word if certain words are in front of it. /(?<!(Gold|Pink)\s)Rathian/ matches "Rathian" only if it is not preceded by "Gold" or "Pink" (so "Gold Rathian" is not a match)
    • Attention: Does not work on some browser (to my knowledge Safari and IE). So this one might break for some people. Usage not recommended if you want to share your lore entries thanks for the heads-up Bunray!)
  • Regex NOT pattern 2 (Valahraban): Does not match a word if certain words are after it. /Deviant(?!\s(Rathalos|Rathian|Monster))/ matches "Deviant" if not followed by "Rathalos", "Rathian" or "Monster" (so "Deviant Monster" is no match)
Clone this wiki locally