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.
- Prepare
- Python
- Regex and Parsing
- Matrix Script
- Discussions
Matrix Script
Matrix Script
Sort by
recency
|
569 Discussions
|
Please Login in order to post a comment
print(re.sub("(?<=\w)(\W+)(?=\w)"," ","".join([matrix[j][i] for i in range(m) for j in range(n)])))
matrix = [list(i) for i in zip(*matrix)] matrix = sum(matrix, []) string = "".join(matrix)
pattern = "[A-Za-z0-9][^A-Za-z0-9]+[A-Za-z0-9]"
betweens = re.findall(pattern, string) for substr in betweens: string = string.replace(substr[1:-1], ' ', 1)
print(string)
this is my code, I replace positive lookbehind and positivei lookahead condition into \b meta string.