javascript - ReplaceAll Google script -


i've got problem, trying use replace function in javascript , cannot work. i'm using:

var pagename = projectname.replace (" ", ""); 

but takes first space, wanted take spaces. example:

"my first project 1" = "myfirstproject1", ie together.

i'm developing script of google apps.

thank you.

you should try :

var pagename = projectname.replace (/\s/g, ''); 

the g @ end of regular expression, flag indicating replace method shouldn't replace first occurrence of space character.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -