Are Regular Expressions in Test Cases for Class Assignments Working?
JohnDutton (4)

I am trying to use regular expressions in test cases and I am unable to get anything other than literal matching to work. Specifically, I am trying to check the output of:

print ("Hello World")

and I have set the regular expression to each of the following without success:

/Hello World/i
/Hello World/
new RegExp(/Hello World/i);

Is this functionality working and I am missing some documentation?

You are viewing a single comment. View All
mat1 (3288)

Hey, can you please give us a Repl link so we can help you?
If this is JavaScript, then you need to put a semicolon at the end of the line.
If this is Python, then regexes don't work like that so here's some quick documentation for you. https://docs.python.org/3/library/re.html

Please upvote my comment if it was helpful or useful in any way

JohnDutton (4)

@mat1 This is inside of a test case for a class assignment. It seems that the test cases allow for JS inside since it references https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp in the help. But I've tried every possible permutation of the regular expression to get the test case to work with no luck.

Edit: To clarify, I can't provide a Repl link because it's not on a project, it's about a feature of Repl itself.

n_frost (2)

@JohnDutton Did you ever receive a reply or do you have any idea how to fix, as I can't get it working either (and the 'example' they give doesn't work).

JohnDutton (4)

@n_frost I have received neither. Good to know I'm not the only one!

darrylluther (2)

How did this get marked as an answer? It doesn't address the question at all, let alone answer it.