Answer the question
In order to leave comments, you need to log in
How to make the regular in google apps script in spreadsheets replace not the first match found, but all?
I know about the global flag, but it doesn't work for some reason. Maybe I'm doing something wrong...
function myFunction() {
phone="097-888-88-88";
phone = phone.replace('-', '', 'g')
Logger.log(phone);
}
var regex = new RegExp('-', 'g');
phone = phone.replace(regex, '', 'g');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question