Issue
I want to replace multiple characters from my phone number data string.
Input data is this
+1 305-267-2700,+1 305-762-3890,+1 786-728-3885,+1 305-567-9589,+1 786-619-7070,+1 786-316-3187,
In some cases, there is + before the number and in some cases, there is space or -, so I want to remove them or replace them with nothing.
These are the characters I want to remove
“+”
“-”
“Space”
Zapier allows me to use javascript or python, what code can I use in there to replace these characters?
This is how the page where we enter the code in Zapier looks for reference, am new to this so not sure how all these work.
enter image description here
Solution
Python
Use str.replace
to replace the character you want to remove with an empty string ''
string = "+1 305-267-2700,+1 305-762-3890,+1 786-728-3885,+1 305-567-9589,+1 786-619-7070,+1 786-316-3187"
string = string.replace("+", "").replace("-", "").replace(" ", "")
JavaScript
string = "+1 305-267-2700,+1 305-762-3890,+1 786-728-3885,+1 305-567-9589,+1 786-619-7070,+1 786-316-3187"
string = string.replaceAll("+", "").replaceAll("-", "").replaceAll(" ", "")
Answered By – Tantary Tauseef
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0