TinyTechZinc / WordFinder

A simple app for learning how to use MAUI and Google Play
MIT License
0 stars 0 forks source link

Not At Position rule causes the word to be longer #15

Open TimothyZink opened 2 hours ago

TimothyZink commented 2 hours ago

Introduced by #14 If a not-at-position rule refers to a position beyond the last required word, it causes the required length to be extended. Shown below is an example and its resulting regex. The not-at-position rule causes filler to be added, incorrectly making the word longer. A better way would be to replace .{6}[^c\n].* with (.{0,5}|.{6}[^c\n].*) This is only needed if there are no future at-position rules or exact/min word length that requires it to be that long regardless.

^(?<word>(?=(.*[t].*){1,})(?=(.*[h].*){1,})(?=(.*[i].*){1,})(?=(.*[n].*){1,})(?=(.*[g].*){1,}).{2}[e].{6}[^c\n].*)$

image

TimothyZink commented 2 hours ago

A potential solution would be to check the max position for at-position rules and check the exact/min length. If the not-at-position rule is beyond either, then use the or operator.