I am receiving a tokenized string from the server in the form of status---delimiter---status where I may have up to 1000 statuses. There are only 6 different possible values for status. I am trying to find a way to search for all 6 at once and that gives me a count of each. I've come up with several less optimum ways of solving the issue but the best I could think of still effectively makes 2 full passes on the string and involves several substeps. I looked at regX .match and capture groups but couldn't seem to find any way to make that work better then one status at a time. I realize the performance difference wont be noticeable but now I just want to know, since in theory this should be doable (though maybe not with JavaScripts regX).
Example Set of statuses: [red,blue,green,orange,purple,pink] Delimiter (I can chose this): | String: red|purple|green|red|blue|orange|purple|blue
Result: [red: 2, blue: 2, green: 1, orange: 1, purple, 2, pink 0]