in reply to Using a regex search pattern

In your regex, /<BOXIND NUM=\"(.+)\" ID=\"(.*?)\"\/>/g, the .+ part is greedy and gobbles up too much. You want .+?, or better, [^"]+ in there to stop the regex from matching outside of the attribute field.

Maybe you want to look at XPath and/or an HTML parser instead, at least if your task is anything beyond simple extraction ;)