- String manipulation functions
- cstr_escape()
- json
.escape() - regsub()
- regsuball()
- std
.anystr2ip() - std
.atof() - std
.atoi() - std
.ip() - std
.ip2str() - std
.prefixof() - std
.str2ip() - std
.strlen() - std
.strpad() - std
.strrep() - std
.strrev() - std
.strstr() - std
.strtof() - std
.strtol() - std
.suffixof() - std
.tolower() - std
.toupper() - substr()
- urldecode()
- urlencode()
- utf8
.codepoint_count() - utf8
.is_valid() - utf8
.strpad() - utf8
.substr()
std.str2ip()
Converts the string representation of an IP address (IPv4 or IPv6) into an IP type
. If conversion fails, the fallback will be returned. The string must be a numeric IP address representation in the standard format such as 192.0.2.2
and 2001:db8::1
. This function does not support looking up an IP address by name.
We recommend using a fallback IP address that's meaningful for your particular Fastly service.
Format
IP
std.str2ip(STRING addr, STRING fallback)
Examples
1
2
3
if (std.str2ip(req.http.Fastly-Client-IP, "192.0.2.2") ~ my_acl) {
...
}