how to replace multiple characters in a string?

python, python-3.x, replace, string

Solution

You can use re.sub():

import re
newName = re.sub('[\\\\/:*?"<>|]', 'special char', name)

Problem

how to replace multiple characters in a string? please help to fix the script I need to in the line "name" special characters have been replaced by the phrase "special char" ``` newName = replace(name, ['\', '/', ':', '*', '?', '"', '<', '>', '|'], 'special char') ``` but I get the message: invalid syntax

Original source