I’m currently programming a vocabulary algorithm that checks if a user has typed in the word correctly. I have the following situation:
The correct solution for the word would be “part1, part2”.
The user should be able to enter either “part1” (answer 1), “part2” (answer 2) or “part1, part2” (answer 3).
I now try to match the string given by the user with the following, automatically created, regex expression:

^(part1|part2)$

This only returns answer 1 and 2 as correct while answer 3 would be wrong. I’m now wondering whether there’s an operator similar to | that says and/or instead of either...or.

May anyone help me solve this problem?

6 Answers
6

Leave a Reply

Your email address will not be published. Required fields are marked *