求正则,'str1','str2,','str3'....。
在一个TextField里输入一个东西,要是'str1','str2,','str3'这样的格式,可以是'str',也可以是'str','str'...请大家帮帮忙,或者写一段javascript代码也可以。

解决方案 »

  1.   

    Array join 参阅这两个就OK了.
      

  2.   

    /^'\w+',?$/可以基本满足,但是有一点就是可以匹配'str',这种的,最后一个字符是逗号的话也能匹配,
    最好是这样:
    var val = document.getElementById("textId").value;
    var pattern = /^'\w+'$/;
    if (val != "") {    arr = val.split(",");
        for (i = 0; i < arr.length; i++) {        if (arr[i] != "" && !arr[i].match(pattern)) {
                alert("error!");
            }
        }
    }
      

  3.   

    3. If user select the option "in", more than one value can be input quote by a pair of " " and separate by a comma. e.g.("value1", "value2", "value3"), the field shall be validated if any "," (comma) inputted.
    需求是这样的,也就是说,好像上面的都有忽略了""这个
      

  4.   

    楼主是什么意思,是说‘value’和"value"都是满足条件的吗
      

  5.   

    3. If user select the option "in", more than one value can be input quote by a pair of " " and separate by a comma. e.g.("value1", "value2", "value3"), the field shall be validated if any "," (comma) inputted. 这是需求
    不,是我写错了,"value","value",……才满足,这里的value只是个值,可以是字符串,
    3. If user select the option "in", more than one value can be input quote by a pair of " " and separate by a comma. e.g.("value1", "value2", "value3"), the field shall be validated if any "," (comma) inputted. 在这需求里他说 more than one value can be input quote by a pair of " " and separate by a comma.,也就是至少有两个的值,这些值是要用""包起来的,而且值之间是要用逗号隔开的
      

  6.   

        var pattern= /^"\w+","\w+"(,"\w+")*$/;
        var val = document.getElementById("textbox的id").value;    if (!val.match(pattern)) {
            alert("error");
    } else {
            alert("OK");
        }