I was trying a simple regex search to check for validity of an IPv6 address. I first tried a simple example for searching simple hex characters in a 4 block system.
For eg:
The string - acbe:abfe:aaee:afec
I first used the following regex which is working fine:
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> r = re.compile("[a-f]{4}:[a-f]{4}:[a-f]{4}:[a-f]{4}")
>>> s = "acbe:abfe:aaee:afec"
>>> r.findall(s)
['acbe:abfe:aaee:afec']
Then I tried a different regex since it is repeating:
>>> r = re.compile("([a-f]{4}:){3}[a-f]{4}")
>>> r.findall(s)
['aaee:']
Note only part of the address is returned. When tested on the regex testing website RegexPal, it matches the full addresss.
Why isn't the whole address matched? Doesn't python support grouping of complex regex?