String Replace Python Re - Basic usage Use the replace () method to replace substrings. str.replace () — Python 3.11.3 documentation Specify the old string old for the first argument and the new string new for the second argument. s = 'one two one two one' print(s.replace(' ', '-')) # one-two-one-two-one source: str_replace_translate.py 4 Answers Sorted by 716 str replace v2 v3 does not recognize regular expressions To perform a substitution using a regular expression use re sub v2 v3 For example import re line re sub r i interfaceOpDataFile interfaceOpDataFile s fileIn line
String Replace Python Re

String Replace Python Re
477 This question already has answers here : How to input a regex in string.replace? (7 answers) Closed 6 years ago. I am trying to do a grab everything after the '