String.prototype.split

/*
官网原文:
    ES3 states that “If separator is a regular expression that contains capturing parentheses, then each time separator is matched the results (including any undefined results) of the capturing parentheses are spliced into the output array.” JScript ignores the capturing parentheses. FF outputs empty strings instead of undefined.
*/
   alert("A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/));
/*
    Output: IE: A,bold,and,coded 
            FF: A,,B,bold,/,B,and,,CODE,coded,/,CODE,
         Opera: same as FF 
        Safari: same as IE
*/

你可能感兴趣的:(prototype,IE,Opera,Safari)