thread: Fix regex for ticket # in email subject

The ticket number regex was changed with the advent of custom ticket numbers, and it matches the closing punctuation in [#12345], that is, the closing bracket would be included in the ticket number sought in the database. Therefore, it would never match the ticket number properly.

The new regex attempts to match punctuation and non-punctuation groups so that punctuation in the middle of the ticket number is matched; however, punctuation at the end is not. So #12345+DEPT will match properly and will ignore any trailing whitespace and punctuation.