Would a regular expression be faster than the following Python code?
myStr.replace(","," ").replace("'"," ").replace("-","").replace("_","").replace("["," ").replace("]"," ")
Does this mean that the str is being iterated over 6 times(the number of replace() calls)? Would a regular experession be faster or is it the same algorithm/methodlogy?
What would the regular expression of this look like?
I would say that a regex would almost certainly be faster, but you should do a simple benchmark to find out for sure. The code you have performs the following separate steps
and could be done in two steps with regexes: