remove trailing semicolon etc from matchgroup