膜拜了,javascript水好深啊 Kevin

请将All over the world people enjoy sports替换成All1 over2 the3 world4 people5 enjoy6 sports7

 

 

 

 

 

 

 

大牛的实现:

var i = 0, str = "All over the world people enjoy sports";
str = str.replace(/\S+/g, function($){return $ + [++i]});
alert(str);

原文地址:https://www.cnblogs.com/kfx2007/p/2444237.html