Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Extract domain from text in Mandarin
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
從文章內容,擷取網址中的網域部分 {{LanguageSwitcher | content = [[Extract domain from text | English]], [[Extract domain from text in Mandarin | 漢字]] }} === 使用 Google sheet 擷取網域 === 使用 Google 試算表 [https://support.google.com/docs/answer/3098244?hl=zh-Hant REGEXEXTRACT] 函數 <pre> =REGEXEXTRACT(A1, "(http[s]?\://[^/]+)") </pre> 輸入文字內容: <pre> Yahoo! 新聞 https://tw.news.yahoo.com/abc </pre> 輸出: <pre> https://tw.news.yahoo.com </pre> 說明: # 網域指以 <nowiki>http://</nowiki> 或 <nowiki>https://</nowiki> 開頭,與相臨不是符號 {{kbd | key = <nowiki>/</nowiki>}} 的多個文字:{{kbd | key = <nowiki>[^/]+</nowiki>}}。 == 資料驗證:文章內容是否包含網域 == 原始資料包含網域,但是網域前面不包含 http e.g. tw.news.yahoo.com 或 www.bbc.co.uk。使用 Google 試算表 [https://support.google.com/docs/answer/3098292?hl=zh-Hant REGEXMATCH] 函數,符合正規表示法的規則的話,回傳 TRUE。若不符合,則回傳 FALSE。 {{exclaim}} 以下語法未處理 [https://zh.wikipedia.org/wiki/IPv4 IPv4] 形式的網域。(如果網域前面包含 http ,則可直接搜尋關鍵字: regular expression extract host ) <pre> =IF(ISERROR(REGEXMATCH(A1, "([a-zA-Z0-9\-_\\._~\:\/\?#\[\]@\!\$&'\(\)\*\+,;\=%]+\.[a-zA-Z]{2,}$|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})")), FALSE, REGEXMATCH(A1, "([a-zA-Z0-9\-_\\._~\:\/\?#\[\]@\!\$&'\(\)\*\+,;\=%]+\.[a-zA-Z]{2,}$|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})")) </pre> 輸入1: <pre> www.bbc.co.uk </pre> 輸出1: <pre> TRUE </pre> 輸入2: <pre> 127.0.0.0 </pre> 輸出2: <pre> TRUE </pre> 輸入3: <pre> Yahoo! 新聞 </pre> 輸出3: <pre> FALSE </pre> 不建議的其他方法: * 檢查網域結尾是否是 .com, .tw, .net, .org 因為太多要列舉,該方法沒有效率。 [[Category: Regular expression]] [[Category: Data Science]] [[Category: String manipulation]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki共筆:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Exclaim
(
edit
)
Template:Kbd
(
edit
)
Template:LanguageSwitcher
(
edit
)