Pattern: IPv6 Address

“IPv6 address” is one of the patterns that you can select on the Match panel. Use it to make a field match an internet address such as 1762:0:0:0:0:b03:1:af18 or 1762::b03:1:af18.

  1. Click the New Formula button on the top toolbar to clear out all settings on the Samples, Match, and Action panels.
  2. On the Samples panel, paste in one new sample:
    1762:0000:0000:0000:0000:0b03:0001:af18
    1762:0000:0000:0000:0000:0B03:0001:AF18
    1762:0:0:0:0:b03:1:af18
    1762:0:0:0:0:B03:1:Af18
    ff01:0:0:0:ca:0:0:2
    0:0:0:0:0:0:0:1
    0:0:0:0:0:0:0:0
    1762::0b03:0001:af18
    1762::b03:1:af18
    ff01:7:ca::
    ::ff01:7:ca:0
    ::1
    1::
    ::1:2:3:4:5:6:7
    1:2:3:4:5:6:7::
    0:0:0:0:0:0:127.32.67.15
    0:0:0:0:0:ffff:127.32.67.15
    ::127.32.67.15
    ::ffff:127.32.67.15
    ffff::127.32.67.15
    ::1:2:3:4:5:127.32.67.15
    
    1762:0:0:0:0:b03:1:af18/128
    1762:0:0:0:0:b03:1:af18/96
    1762:0:0:0:0:b03:1:af18/8
    
  3. Set the subject scope to “line by line”.
  4. On the Match panel, set “begin regex match at” to “start of text”, and set “end regex match at” to “end of text”.
  5. Click the Add First Field button to add field 1.
  6. In the “pattern to match field” drop-down list, select “IPv6 address”. By default, this pattern matches any IPv6 address in dotted notation.



  7. Check the notations you want to allow. In this example, we enable the standard and compressed notations, which are the most common ones.
  8. Uncheck “require leading zeros” to allow leading zeros to be omitted.
  9. Set the “field validation mode” to “strict”.
  10. On the Regex panel, select “POSIX ERE” as your application. This is a basic regular expression flavor which ensures your regex will be compatible with most log analysis tools. It does not support free-spacing or mode modifiers, so those options are forced off. Click the Generate button, and you’ll get this regular expression:
    ^([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}$
    Required options: Case insensitive; ^$ don’t match at line breaks; dot matches line breaks.
  11. The Samples panel now highlights the IP addresses in the range that we specified:
    1762:0000:0000:0000:0000:0b03:0001:af18
    1762:0000:0000:0000:0000:0B03:0001:AF18
    1762:0:0:0:0:b03:1:af18
    1762:0:0:0:0:B03:1:Af18
    ff01:0:0:0:ca:0:0:2
    0:0:0:0:0:0:0:1
    0:0:0:0:0:0:0:0
    1762::0b03:0001:af18
    1762::b03:1:af18
    ff01:7:ca::
    ::ff01:7:ca:0
    ::1
    1::
    ::1:2:3:4:5:6:7
    1:2:3:4:5:6:7::
    0:0:0:0:0:0:127.32.67.15
    0:0:0:0:0:ffff:127.32.67.15
    ::127.32.67.15
    ::ffff:127.32.67.15
    ffff::127.32.67.15
    ::1:2:3:4:5:127.32.67.15
    
    1762:0:0:0:0:b03:1:af18/128
    1762:0:0:0:0:b03:1:af18/96
    1762:0:0:0:0:b03:1:af18/8
    

Related Examples

Reference