You can always do this for ipv6: if re.search('\(([0-2]?\d{0,2}\.){3}([0-2]?\d{0,2})(:S\.\d+){0,1}\)$', login) or re.search('\(([\da-fA-F]{1,4}:){7}([\da-fA-F]{1,4})(:S\.\d+){0,1}\)$', login) but I haven't tested that
You can always do this for ipv6: '\(([0- 2]?\d{0, 2}\.){3} ([0-2]? \d{0,2} )(:S\.\ d+){0,1} \)$', login) or re.search( '\(([\da- fA-F]{1, 4}:){7} ([\da-fA- F]{1,4} )(:S\.\ d+){0,1} \)$', login)
if re.search(
but I haven't tested that