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

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -