Regular expression flavor?

Regular expression flavor?

de către Miguel Rubio-
Număr de răspunsuri: 2

Hello,

First of all I would like to thank all the people involved in this project. We are using it in our CS1 course and finding it very useful.

We are using the regular expression grading and we would like to know the underlying engine. After browsing the code we believe it is a PHP-style PERL engine but would like to confirm it.

Miguel Ángel Rubio

Department of Computer Science

University of Granada

Ca răspuns la Miguel Rubio

Re: Regular expression flavor?

de către Richard Lobb-

Hi Miguel

Good to know you're finding CodeRunner useful.

The two relevant PHP lines are

        $regex = '/' . str_replace('/', '\/', rtrim($testcase->expected)) . '/ms';
        $iscorrect = preg_match($regex, $output);

So matching is done by a call to PHP's "PERL regular expression match" function - essentially the entire student output is searched for any embedded occurrence of the given regular expression. The regular expression is that supplied in the question authoring form ($testcase->expected), trimmed and wrapped in slashes ('/'s) after escaping any existing slashes. The 'ms' modifiers are PCRE_MULTILINE and PCRE_DOTALL, so that '^' and '$' match at the start and end of lines, rather than just at the start and end of the entire output string and '.' matches all characters including newlines.

Richard