哪位高手能给举例说明一下修饰符y的用途,举个简单的例子详细说明一下

解决方案 »

  1.   

    x|y 匹配x或y   楼主是这意思?http://www.w3cschool.cn/jsref_obj_regexp.html有时间去w3c看看吧,教程
      

  2.   

    i 表示忽略大小写
    s 表示单选匹配
    m 表示多行匹配木有见过y表示神马意思
    y只能说明匹配字母y而已
      

  3.   

    New in Firefox 3 Non-standard 
    sticky; matches only from the index indicated by the lastIndex property of this regular expression in the target string (and does not attempt to match from any later indexes). This allows the match-only-at-start capabilities of the character "^" to effectively be used at any location in a string by changing the value of the lastIndex property.
      

  4.   


    function print(str){
    document.write(str);
    document.write("<br/>");
    }
    var text = "First line\nsecond line";
    var regex = /(\S+) line\n?/y;
    var match = regex.exec(text);
    print(match[1]);  // prints "First"
    print(regex.lastIndex); // prints 11
    var match2 = regex.exec(text);
    print(match2[1]); // prints "Second"
    print(regex.lastIndex); // prints "22"
    var match3 = regex.exec(text);
    print(match3 === null); // prints "true"