我有以下文字:
Title %%% info@mydomain.com
我有以下脚本:
update: function(){
this.AjaxImage(this.mainImage.current);
// /[$-/:-?{-~!"^_`\[\]]/ Updated 05.22.10, changed .replace(/%%%[^%]*/,' ') to .replace(/%%%.*/,' ') because an escaped space (%20) was causing markup to appear on the page. DE
// only show the title and year below the image, %%% is the delimiter
var caption = this.detailBin[this.mainImage.current]
.innerHTML.replace(/%%%.*/,' ');
this.overlayCaption('hide');
this.controls.counter.update(this.mainImage.current+1);
this.utilities.updateHash(this.mainImage.current+1);
this.captionUnderlay.update(caption);
// show everything under "more info"
this.captionText = this.detailBin[this.mainImage.current]
.innerHTML.replace('%%%',' ');
this.hasMoreInfo = (this.captionText.length > caption.length+9) ? true : false;
if(!this.hasMoreInfo)
this.controls.captionToggle.hide();
else
this.controls.captionToggle.show();
}
this.captionUnderlay.update(this.detailBin[this.currentImage]
.innerHTML.replace(/%%%[^@]*/," "));
上面的标题Underlay 将显示@mydomain.com
。
我可以使用下面的 kludge 解决问题,但我想了解问题所在(我正在接管其他人编写的代码)。
如果我[^@]
从正则表达式中删除,它会显示所有内容。如果我用它代替[^@]
它[^}]
,除非我}
在文本中有一个。
如何防止这种情况发生?