I have code with lines that look like this:
self.request.sendall(some_string)
I want to replace them to look like this:
self.request.sendall(bytes(some_string, 'utf-8'))
This is my current sed command:
sed -i "s/.sendall((.*))/.sendall(bytes(1, 'utf-8'))/g" some_file.py
I'm close, but this is the result I'm getting:
self.request.sendall(bytes((some_string), 'utf-8'))
I can't figure out where the extra open and close parenthesis are coming from in the group substitution. Does anyone see it? The escaped parenthesis are literal and need to be there. The ones around .* are to form a group for later replacement, but it's like they are becoming part of the matched text.
question from:
https://stackoverflow.com/questions/65829132/why-are-there-extra-parenthesis-in-this-regex-substitution 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…