If you want to totally ignore the preceding characters and capture only the last 5 (or 16, or however many characters you want), use the \b (word boundary) and \B (non-word boundary) characters together:
(\B[a-f\d]{5}\b)
abdsadsajkeaw_12345
bdGdsadsa_jkeaw_abcde
ass0012_67890
In this example code, the \B will ensure that there is no space between the '_' character and the last 5 characters, as you don't want it to capture if the word is ONLY 5 characters long.
Then it searches for {5} characters that fit within the range of [a-f] or a digit (\d) -- which you can easily modify to be whatever characters you need.
Last, it ensures that the last of the {5} characters is not followed by another character: it is at the word boundary.
Putting everything within () parentheses ensures that you capture those characters, for use later as a \1 replacement.