• + 0 comments

    this is my code, I replace positive lookbehind and positivei lookahead condition into \b meta string.

    import math
    import os
    import random
    import re
    import sys
    
    
    
    N, M = map(int, input().split())
    
    matrix = []
    
    for _ in range(N):
        matrix_item = input()
        matrix.append(matrix_item)
    
    string = ''.join(matrix)
    decode = '' 
    
    for i in range(M):
        for index in range(i, len(string), M):
            decode += string[index]
            
    decode = re.sub('\\b\W+\\b', ' ', decode)
    print(decode)