I am working on writing test cases for student problems on replit. I don't want students to have to match my output exactly for their problems, but their solutions do need to contain the correct answer. For example, here is a simple program that asks students to input a number, a mass and then a date and outputs some results.
Please enter a number between 1 and 10 (inclusive): 8
The Roman number for 8 is VIII.
Please enter the mass in kg: 90
The weight of 882.0000000000001 is just right.
Please enter the 2 digit month: 06
Please enter the 2 digit date: 10
Please enter the 2 digit year: 60
The date 6/10/60 is magic
I would like for the students to have their output have any text they choose as long as they have the correct answers (IX, 578.2 and "is magic") for this particular set of data.
I need to use regex test for this however, I have not been successful in writing a regex that works.
Note My regex experience is limited. I used chatGPT to get started. I then put the output from chatGPT into regex101.com and used the debugger so I could follow the steps the parser (?) was taking to move through my answer vs. the expression.
Here are my various attempts (I modified these serval times as well but you get the gist).
[a-zA-Z0-9:\.\(\)]+VIII[\n\.:a-zA-Z0-9]+882.0000000000001+[\n\.:a-zA-Z0-9]+is magic[\n\.a-zA-Z0-9]
\b\w+(?:\s+\w+)*\s+VIII\b[\w\s\d,:.]+882[\w\s\d,:.]+\bis magic\b
\b\w+(?:\s+\w+)*\s+VIII\b\w+[?:\w+\s+\d,:.]+882.0000000000001\b\w+[\w+\s+\d+,\/:.]+\bis magic\b
.*?VIII\n.*?882\n.*?is magic\n
None of the above regexes nor their variations worked with the output in bold above. One of my guesses is that the \n
is causing problems but I couldn't prove or disprove that theory....
Thanks much in advance.