I have two outputs of two commands (it doesnt matter the content, the thing is that I have to replace for both the same characters):
string1 = str(newstring1).replace("\\r", "").replace(" ", "").replace("\\", "").replace("' ", "").replace("\n", ", ").replace("MB ", "MB").replace("MB", "MB ")
string2 = str(newstring2).replace("\\r", "").replace(" ", "").replace("\\", "").replace("' ", "").replace("\n", ", ").replace("MB ", "MB").replace("MB", "MB ")
That works, but my question is, Is there any way to do those "replaces" just once? Instead of doing this two times.
I tried creating a variable with .replace("\\r", "\n").replace("[", "").replace("'", "").replace(" ", "").replace(",", "").replace("]", "").replace("\n ", "\n").rstrip().lstrip().replace("MB ", "MB").replace("MB", "MB ") but it does not work.