Use the replace() method to replace multiple characters in a string, e.g. str. replace(/[. _-]/g, ' ') .
Use the translate() method to replace multiple different characters. You can create the translation table specified in translate() by the str. maketrans() . Specify a dictionary whose key is the old character and whose value is the new string in the str.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With