Fix missing groups in imenu indexing
Fix regexp patterns to never match empty strings

Always match at least the final part of the name, to make sure that we
never match empty strings.