GitHubContribute in GitHub: Edit online

has-ipv6-prefix-function

Returns a value indicating whether one of specified IPv6 address prefixes appears in a text.

 IP-prefix notation is a concise way of representing an IP address and its associated network mask. The format is <base IP>/<prefix length>, where the prefix length is the number of leading 1 bits in the netmask. The prefix length determines the range of IP addresses that belong to the network.

 For IPv6, the prefix length is a number between 0 and 128. So the notation fe80::85d:e82c:9446:7994/120 represents the IP address fe80::85d:e82c:9446:7994 with a netmask of ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00. This netmask has 120 leading 1 bits, or a prefix length of 120.

<p></p>

Syntax

has_ipv6_prefix(text , ip_address_prefix [, ip_address_prefix ...] )

has_ipv6_prefix(text , ip_address_prefixes )

Arguments

  • text: The value containing the text to search in.
  • ip_address_prefix: String value containing the IP address prefix to look for.

Returns

true if the one of specified IP address prefixes is a valid IPv6 address prefix, and it was found in text. Otherwise, the function returns false.

Examples

 

Example 1

Example shows ipv6 prefix is present in the string.

print has_ipv6_prefix('05:04:54 fe80::85d:e82c:9446:7994 GET /testing.ico 404', 'fe80:') // true

 

### Result
print_0
1

 

### Example 2 Example shows ipv6 prefix is not present in the string due to an invalid ipv6 address.

print has_ipv6_prefix('05:04:54 fe80::85d:e82c:9446: GET /favicon.ico 404', 'fe80') // false, invalid IPv6 address

 

### Result
print_0
0
##  Example 3

Example shows improperly delimited ipv6 address in the string.

print has_ipv6_prefix('05:04:54fe80::85d:e82c:9446:7994/127 GET /favicon.ico 404', 'fe80') // false, improperly delimited IP address

 

### Result
print_0
0