String replace spaces ---

 

Title: Please implement a function, a string to replace each space to "20%." For example, when the string is We Are Happy. After the string is replaced after We% 20Are% 20Happy.

 

function replaceSpace(str){

    return str.replace(/\s/g,'%20')

}

 

Guess you like

Origin www.cnblogs.com/mlebk/p/12462655.html