Your case is tricky because if the ID is only letters it could be any part of the sentence. Using the $
, you have told the regex processor to look for the pattern at the end of the sentence. Hence, it only works for those cases.
What you could do is to make use of a non-capturing group provided by the RE2 syntax. There are some examples of non-capturing group here on SO. Basically, search for something like the following (not tested):
(?:serial)(?:number)?[0-9a-zA-Z]+
The first ("serial") would be detected and ignored, the "number" is optional and would be ignored, then comes the alphanumeric.