Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace multiple characters in a string?

Tags:

People also ask

How do you replace multiple letters in a string?

Use the replace() method to replace multiple characters in a string, e.g. str. replace(/[. _-]/g, ' ') .

How do you replace multiple substrings in a string in Python?

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