The problem is in line 15 var index1 = eachFilter[i].match(re1);. Do you understand how match() function works? Have you ever tried to print out what value returned by match() function?
If you do not have grouping in your regex, the function (in JavaScript) will return an array size of 1 if it could match, or null value if it couldn't.
var index1 = eachFilter[i].match(re1);
// this will return [MATCHED_VALUE] to your index1 (in your case)
// but you are using 'i' as index which in the second loop is now 1
// the index1 length is 1, so it has only '0' index and no '1' index
To fix this is to use [0] instead of [i]. However, this will break your script again if there is no match.
By the way, what you are trying to do here? You are not utilizing regex but rather hard-coded it. If you are going to do the way you are doing, using string split() function would be easier.
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17