Regex matching test cases

You can create regex-based test cases with the regex pattern as the expected output. The output of the candidate's code will be matched based on the regex that you provided.

The regex matching can only be enabled if and only if one of the regex-supported languages is selected. The regex pattern should be supported for the regex-supported language selected. The following are the languages that support regex matching:

  • Ruby (2.7.0)

  • Python (3.8.1)

  • JavaScript (Node.js 12.14.0)

For example: You have selected the ruby programming language with /^[0-9]+$/ as expected output. This regex matches the numbers between 0 to 9 in the string. A few possible scenarios could be:

  • If the candidate's output is Hello world , this test case will fail.

  • If the candidate's output is 123 , the test case will pass since the output has numbers 1, 2, and 3 present.

If the question has at least one test case with regex matching enabled, you will see the following warning on the languages tab:

Screenshot 2023-12-12 at 7.25.19 PM.png
Regex matched

Note: If the selected regex-supported language is unselected or any other language is added, the regex matching will be disabled in the test cases where it is enabled.

Can't find what you're looking for?