For the string itself, just do a findall and use the last one:
import re
st='123456 nn1 nn2 nn3 nn4 mlm nn5 mlm'
print(re.findall(r'(nn\d+)',st)[-1])
Prints nn5
You can also do the same thing using finditer
which makes it easier finding the relevant indexes:
print([(m.group(),m.start(),m.end()) for m in re.finditer(r'(nn\d+)',st)][-1])
Prints ('nn5', 27, 30)
If you have a lot of matches and you only want the last, sometimes it makes sense to simply reverse the string and pattern:
m=re.search(r'(\d+nn)',st[::-1])
offset=m.start(1)
print(st[-m.start(1)-len(m.group(1)):-m.start(1)])
Or, modify your pattern into something that only the last match could possible satisfy:
# since fixed width, you can use a lookbehind:
m=re.search(r'(...(?<=nn\d)(?!.*nn\d))',st)
if m: print(m.group(1))
Or, take advantage of the greediness of .*
which will always return the last of multiple matches:
# .* will skip to the last match of nn\d
m=re.search(r'.*(nn\d)', st)
if m: print(m.group(1))
Any of those prints nn5