strings.extract_hostname

以下でサポートされています。
strings.extract_hostname(string)

説明

文字列からホスト名を抽出します。この関数では大文字と小文字が区別されます。

パラメータのデータ型

STRING

戻り値の型

STRING

コードサンプル

例 1

この例では、空の文字列が返されます。

strings.extract_hostname("") = ""
例 2

ランダムな文字列(URL ではない)

strings.extract_hostname("1234") = "1234"
例 3

複数のバックスラッシュ

strings.extract_hostname("\\\\") = ""
例 4

英語以外の文字が適切に処理される

strings.extract_hostname("http://例子.卷筒纸.中国") = "例子.卷筒纸.中国"
例 5

URI の処理

strings.extract_hostname("mailto:?to=&subject=&body=") = "mailto"
例 6

実際の URL の前に複数の文字がある

strings.extract_hostname("     \t   !$5*^)&dahgsdfs;http://www.google.com") = "www.google.com"
例 7

URI 内の特殊文字 #

strings.extract_hostname("test#@google.com") = "test"
例 8

URL 内の特殊文字 #

strings.extract_hostname("https://test#@google.com") = "test"