Python Regex Doubt
Hello everyone, i recently attempted a python regex chalenge and saw the sollution to it and found this: import re first_multiple_input = raw_input().rstrip().split() n = int(first_multiple_input[0]) m = int(first_multiple_input[1]) matrix = [] for _ in xrange(n): matrix_item = raw_input() matrix.append(matrix_item) encoded_string = "".join([matrix[j][i] for i in range(m) for j in range(n)]) pat = r'(?<=[a-zA-Z0-9])[^a-zA-Z0-9]+(?=[a-zA-Z0-9])' print(re.sub(pat,' ',encoded_string)) So my query is that i wasnt able to understand the code after the for loop, pls explain it to me if you can understand it. Reference: Sample input: 7 3 Tsi h%x i # sM $a #t% ir! Sample Output: This is Matrix# %!