【发布时间】:2013-04-11 07:04:59
【问题描述】:
我在 Jquery 中有这段代码 -:
message = '#Usain Bolt #Usain Bolt #Usain Bolt'; message = " "+message+" ";
var type1 = 'Usain Bolt';
if(message.match(type1))
{
var matchOne = new RegExp(' #'+type1+' ', 'g');
var matchTwo = new RegExp('\n#'+type1+' ', 'g');
message = message.replace(matchOne," @"+type1+" ").replace(matchTwo,"\n@"+type1+" ");
}
生成的消息应该是@Usain Bolt @Usain Bolt @Usain Bolt
但它变成了-:@Usain Bolt #Usain Bolt @Usain Bolt
有什么问题。谢谢你的帮助..
【问题讨论】: