正则表达式标志符y什么意思

解决方案 »

  1.   

    global:g
    ignoreCase:i
    multiline:m
    sticky:y
    sticky什么意思
      

  2.   

    哪里看到有y属性的?js规范好像没有这个属性啊
      

  3.   

    x|y  匹配x或y  楼主是这意思?
      

  4.   

    http://www.w3cschool.cn/jsref_obj_regexp.html楼主有时间去看看吧~·
      

  5.   

    从来没有见过y啊
    http://msdn.microsoft.com/zh-cn/library/yd1hzczs.aspx
      

  6.   

    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.
      

  7.   


    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"