in reply to How do remove trailing data?

You can clean it out using regex

s/#\d+$//;