Replace u00A0 with space google script

410 Views Asked by At

I need to replace all instances of the character u00AO with white space. I would like to do this without looping

 var rng = sheet.getDataRange();
     rng.createTextFinder('u00AO').replaceAllWith(" ");

It runs but does not replace the u00AO character with the whitespace in this text

Also, I think that u00AO is the same as chr(160) This does not work either

rng.createTextFinder('chr(160)').replaceAllWith(" ");

In VBA I just do this

rng.Replace "u00AO", " ", 2

Or this

rng.Replace what:=Chr(160), Replacement:=" "
1

There are 1 best solutions below

0
On

this works

function ReplaceALL() {
var ss    =SpreadsheetApp.getActiveSpreadsheet();
var sheet =ss.getSheetByName("A");

 sheet.createTextFinder('\u00A0').replaceAllWith(" ");

}