improved regex (made it more robust); fixed slight bug: empty string '' would incorrectly occur as last item to process; provided tests