it'll fail if for some reason the parent doesn't have an ID, this could do with being handled a bit more gracefully otherwise you'll run into errors such as:
undefined is not an object (evaluating '$parent.attr('id').match')
Probably worth just checking $parent.attr('id') exists first.