我有简单的脚本,我想获取我的图像,然后用逗号分隔它们。但是,[gallery]
自从我得到Uncaught SyntaxError: Invalid regular expression: missing /
.
有人可以看看并告诉我我的 RegEx 代码中的问题在哪里吗?
HTML
<textarea>
abc
[gallery]/content/img/upload/img-2012.03.19.-634677727044317051.jpg, /content/img/upload/img-2012.03.19.-634677727046997204.jpg, /content/img/upload/img-2012.03.19.-634677727049487347.jpg, /content/img/upload/img-2012.03.19.-634677727051787478.jpg, /content/img/upload/img-2012.03.19.-634677727054137613.jpg[/gallery]
def
</textarea>
JavaScript
$(function(){
var text = $('textarea').val();
var re = /\[gallery\]([^}]+)[/gallery\]/g;
var gallery = re.exec(text);
alert(gallery);
});
小提琴:http: //jsfiddle.net/BcFsg/