I have regular expression \n([\d])
that can match this following text:
Then I want to replace that matched text with first group or $1
in Visual Studio Code. This is the result:
I want the same idea in python, which I already make this code.
import re
file = "out FCE.txt"
pattern = re.compile(".+")
for i, line in enumerate(open(file)):
for match in re.finditer(pattern, line):
print(re.sub(r"\n([\d])", r"\1", match.group()))
But that code does nothing to it. Which mean the result is still the same as the first picture. Newlines and the line with numbers at first character are not removed. I already read this answer, that python is using \1
not $1
. And yes, I want to keep the whitespaces between in order to be neat as \t\t\t
.
Sorry if my explanation is confusing and also my english is bad.