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
|
328 Discussions
|
Please Login in order to post a comment
This works with PyPy3. Thank you codersaad for the idea. This is the same code but without a function.
import re
n = int(input())
for _ in range(n): regex = input().strip() try: if re.search(r'(*|+|\?){2,}', regex): print("False") else: re.compile(regex) print("True") except re.error: print("False")
This works with PyPy3. Thank you codersaad for the idea. This is the same code but without a function.
import re
n = int(input())
for _ in range(n): regex = input().strip() try: if re.search(r'(*|+|\?){2,}', regex): print("False") else: re.compile(regex) print("True") except re.error: print("False")
my solution: import re for i in range(int(input())): try: re.compile(input()) print(True) except re.error: print(False) but it is giving output as TRUE TRUE and hence failing the sample test case. Although i did solve it using python 2 can anyone help me with a pypy3 solution
This works for Python 3 import re if name == 'main': n = int(raw_input()) for i in range(n): try: re.compile(raw_input()) print("True") except re.error: print("False")
true true this code is Als gave me