Checks whether a text value is a valid IPv6 address
=LET(
s, TRIM(TO_TEXT(ip)),
REGEXMATCH(
s,
"^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){1,4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){1,3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){1,2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:((:[0-9A-Fa-f]{1,4}){1,6}))|(:((:[0-9A-Fa-f]{1,4}){1,7}|:)))$"
)
)This function checks whether a text value represents a valid IPv6 address, including compressed forms that use "::" to shorten runs of zeros. It's useful for validating imported logs, filtering datasets, or catching typos in IPv6 values. For example, if A2 contains "2001:db8::1" then =IS_VALID_IPV6(A2) returns TRUE, and if A3 contains "2001:db8:::1" then =IS_VALID_IPV6(A3) returns FALSE.
Use the inputs below to create IS_VALID_IPV6 as a reusable custom function in Google Sheets.
Learn how to add custom functions to Google SheetsIS_VALID_IPV6
Checks whether a text value is a valid IPv6 address
=LET( s, TRIM(TO_TEXT(ip)), REGEXMATCH( s, "^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){1,4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){1,3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){1,2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:((:[0-9A-Fa-f]{1,4}){1,6}))|(:((:[0-9A-Fa-f]{1,4}){1,7}|:)))$" ) )
ip
IPv6 address to validate
A2
Other functions in the same category: Data Validation
Checks whether a text value is a valid IPv4 address
Checks whether a text value is a valid ISBN-10
Checks whether a text value is a valid ISBN-13
Checks whether a text value matches a basic email address format
Checks whether a text value matches a basic HTTP/HTTPS URL format
Checks whether a text value matches a standard UUID format
Named functions enable the creation of custom, reusable formulas that mimic built-in functions, streamlining calculations and data manipulations. These functions simplify complex formulas, making spreadsheets more readable and less prone to errors. By encapsulating intricate logic within a single function call, they enhance consistency across your data. Utilizing named functions reduces the need to write lengthy formulas repeatedly, thereby improving workflow efficiency and productivity in data analysis and management.
Download and import — fastest way to add the function but does not include argument descriptions and examples
Follow these simple steps to download and import a function into your spreadsheet. This method is the quickest and easiest way to add the named function to your Google Sheets document, but will not include the argument description and examples.
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.
Copy and paste — copy and paste each property one at a time
Follow these simple steps to integrate a custom named function into your spreadsheet:
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.