User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:220.127.116.11) Gecko/20060111 Firefox/18.104.22.168 When trying to split a string into an Array using a RegExp to match delimiters, Firefox incorrectly includes the delimiters as values. Reproducible: Always Steps to Reproduce: var v; v="12:00 PM".split(/(\s|:)/g); Actual Results: v="12,:,00, ,PM" Expected Results: v="12,00,PM"; Both Internet Explorer 6 and Safari 2.0.3 handle this code correctly. Tested with FF 22.214.171.124 on XP SP2 and OSX 10.4.5.
That is as it should be. From the spec: 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. (For example, "A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/) evaluates to the array ["A", undefined, "B", "bold", "/", "B", "and", undefined, "CODE", "coded", "/", "CODE", ""].)
My mistake. The RegExp I really need is /[\s:]/g. Since both IE and Safari produced the results I wanted, I assumed FF had the bug. Will submit this bug to MS & Apple.