Closed iminlikewithyou closed 10 months ago
after (a lot) of reading over the old code, i'd like to lay out what the old design was and how i'm thinking about rewriting it.
the old way i wrote the regex code was based around ALL regex being written in a way that could match single lines in a dictionary using the global and multiline flags. so a regex as simple as /AB/
(which should match AB
in any word) had to be written as /^.*(AB).*$/
instead, where the anchors match the start and end of lines in a multiline dictionary, the .*
matched "flexible space", and the capturing group was (due to bad foresight) written in a way that was necessary in every regex. the capturing group is there in order to highlight letters in solutions in /solve and at the end of rounds in WBM - but really shouldn't be necessary until those functions are called.
to write out what the new vision is for "prompts" and regex:
"regex prompts" are a type of puzzle in WBM. all prompts can be represented as regex. this is how it worked before, but the layout of the regex (/^.*(AB).*$/
) and wording was scattered and confusing, and i want to make it explicitly clear that all prompts are just regex WITHOUT the extra fancy details. AB
should be /AB/
, and nothing more. instead of doing a global regex over the entire dictionary, we're going to be testing the regex against each word in the dictionary individually, line by line.
ONLY transform a search for AB
into /(AB)/
when searching, where it should be automatically applied (avoiding .* in any regex - as this is classified as "flexible space" and the user usually never wants this part of the regex search highlighted)
ALL prompts in the database for WBM must be converted from their original form to the new, updated form
this PR updates the regex system
/^.*(AB).*$/
, useAB
and automatically apply the capturing group later for rendering. (see this comment)