We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Incorrect Regex
Incorrect Regex
Sort by
recency
|
341 Discussions
|
Please Login in order to post a comment
You should solve this one using Python 2. With Python 3 some test cases won't pass because it's now an accepted regex pattern
this is dumb but... oh well
Changes since 3.11 version has changed the regex interpretation and may not consider right some regex expressions older versions interpret as wrong.
import re
n = int(raw_input())
for _ in range(n): regex = raw_input() try: re.compile(regex) print("True") except re.error: print("False")
Something wonky going on with .+* as a test case which seems to be regex compilable. Does that make it valid? Probably. So stick in a special rule to fudge it to False. Also one of the test cases was failing without the addition of the check on invalid double characters - see below. I think this is again due to changes in language. Maybe we should all be doing this is C which is much more stable :)