iOS Shortcuts match regex not handling NOTs
Running on iOS 16.0 (20A362)
For a bit of fun, i thought I’d try to come up with a shortcut to help play an optimum game of wordle. I have the words in a txt file, each word on its own line. For example:
feast
foist
fried
foray
fancy
froze
fence
fleet
forty
front
fable
forge
frost
facet
flute
flaky
fatty
ferry
folly
I ask for input to ascertain the letters guessed correctly in the correct positions. So for example my regex would correctly tell me that if i guess “ferry” using the sample list above, and i tell the shortcut “fe” were correct and in correct position, it would then tell me that the next best guesses would be “fence” and “feast”. I do this using a loop to first match pattern “f….” , then update the word list with those matches, before next matching pattern “.e…” on the revised list before updating the list again. So far so good!
Next I ask for correct letters that were in the wrong place, and loop through those using “(?=.*Repeat Item).+”. Again this works great BUT, it isn’t enough, as it returns ALL words containing those letters in ANY position - but I also need to exclude those letters from the positions they were in as i know they are NOT there. For example, if when i guessed “ferry” the result had been no letter placed correctly, but just the “f” guessed correctly but in the wrong place, I need to remove all words with “f” in the first letter position and then find all the remaining words that have “f” in position 2,3,4 or 5. This is where things go wrong. If i use the pattern “f….” I will get back a list of all the words starting with “f”. If i then try “[^f]….” I get an error. “There was a problem running your shortcut”. I can’t see what is wrong with my pattern. Similarly, i have tried using the negative lookahead pattern also, and that didn’t work either (but positive lookahead was fine). For example looping though this is fine
(?=.*Repeat Item).+
but this does nothing
(?!.*Repeat Item).+
Anyone got any idea what i am doing wrong here please?
iPhone 12 mini