strings.count_subdomains

Supported in:
strings.count_subdomains(url_string)

Description

Returns the count of all the subdomains that are found in a URL string.

Param data types

STRING

Return type

INT

Code samples

Example 1

This example shows the count of subdomains in a URL string.

strings.count_subdomains("www.sub1.sub2.google.com") = 3
Example 2

This example shows the count of subdomains in a non ASCII URL string.

strings.count_subdomains("http://例子.卷筒纸.中国") = 1
Example 3

This example shows the handling in case the URL is not valid.

strings.count_subdomains("three nine four") = 0
Example 4

This example shows the handling in case the URL is not a registered domain.

strings.count_subdomains("http://localhost:80") = 0
Example 5

This example shows the handling in case the URL has multipart suffix.

strings.count_subdomains("    www.Example.Co.UK    ") = 1