## Question Authors' Forum

### Problem with RegEx Grader and newlines in Expected output

Number of replies: 4

Hello, I've been working on making a series of quizes in order to teach sqlite in a somewhat "gamificated" way (this is still in a very early state). Because of this I've made a question where students are asked to add an element to a table, leaving the contents of said element to their choice.

While I can easily check if a new element has been added since the table has an autoincrement which is used to order the table, using something like ^(number_of_elements_in_table +1).+ to make sure there is one more row on the table, I wanted to check the entire output, to make sure the students only insert a row on the table and nothing more, however pasting the actual output on the expected output doesn't seem to work.

After testing for a while the problem seems to be caused by each newline in the expected output but using \n and/or \r doesn't seem to work.

Shouldn't the output from the run result in a "correct" expected output? What am I doing wrong?

Thanks in advance and sorry if the question is written in an odd way, english isn't my first language.

### Re: Problem with RegEx Grader and newlines in Expected output

by Richard Lobb -
Normally a \n in the test case 'Expected' field will match a single newline character in the 'Got' field. I'm not quite sure why that's not working for you,. It may be that the sql question type (which uses a template written in Python) is stripping out one layer of escaping. Try instead matching the newline with \\n. If that doesn't work, please export an example question as a .xml and I'll have a look at it.

### Re: Problem with RegEx Grader and newlines in Expected output

Yeah, using \\n doesn't seem to work either.
The question has a sample answer, however, since you might want to test, Animal accepts any short char string, Tipo has to be one of the following: Mamifero, Pez, Reptil, Anfibio, Ave, Otros (it's default value is Otros) and Domestico is either Si or No (it's default is No).

### Re: Problem with RegEx Grader and newlines in Expected output

by Richard Lobb -
There's something odd going on at the end of the lines of SQL output that I don't fully understand. Certainly there's at least one extra white-space character of some form at the end of every line but I can't figure out what it is. Regardless, I have found that the following strings will all match the newline:
• \s*\n
• \s*\R
• \s*

As an example, here's an 'Expected' string that matches the second test case output:

7           Perro       Mamifero    Si\s*\n8           Atun        Pez         No

Hope that helps.