Sort by

recency

|

312 Discussions

|

  • + 0 comments

    import re for _ in range(int(input())): try: print(bool(re.compile(input()))) except re.error: print("False")

    Fewer lines of code, but this is wrong in the long run, it's just a joke

  • + 0 comments
    import re
    
    n = int(input())
    
    for _ in range(n):
        regex = input()
        try:
            re.compile(regex)
            print('True')
        except:
            print('False')
    
  • + 0 comments

    import re num=int(input())` for _ in range(num): string=input() try: re.compile(string) print(True) except re.error: print(False)

  • + 0 comments
    import re
    
    T = int(input())
    
    for _ in range(T):  
        try:
            x = re.search(input(), "eheheh")
            print("True")   
        except:
            print("False")
    
  • + 0 comments
            import re
    
            T = int(input())
    
            for _ in range(T):
                    pattern = r"{}".format(input()) # Consider as raw imput to avaid backslash 
                    try:
                            re.compile(pattern)  
                            print(True) 
                    except re.error:
                            print(False)