2015-03-19 4 views

ответ

3

Вы можете использовать replace с Func парам, как

'Macy's'.replace(/&#(.+?);/g,function(_, $1){ 
    return '%'+(+$1).toString(16); //create the new substring (to put in place of the substring received from parameter #1) 
}); //"Macy%27s"