string - Google Apps Script - remove spaces using .replace method does not work for me -


i using google apps script create apps. encounter issue when try remove whitespaces spreadsheet value. have referred alot of posts & comments in stackoverflow , other forum too. talking using .replace method. however, .replace method not work me.

var itemarray = <<getvalue google spreadsheet>> var tvalue = itemarray[0][2].tostring();  (var row = 0; row<itemarray.length; row++) {    var trimmedstra = itemarray[row][2].tostring().replace(' ', '');    var trimmedstrb = tvalue.replace(' ', '');     if (trimmedstra == trimmedstrb)    {       <<other code>>     } //end if } //end of loop 

a simple regexp object should used in replace() method. \s simple solution find whitespace. 'g' provides global match instances of whitespace.

t.value.replace(/\s/g, "")  

this pretty close without knowing data looks like.

.replace() documentation here.


Comments

Popular posts from this blog

Pull out data related to my apps from Android Play Store and iOS App Store -

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -