Extract url from text
Jump to navigation
Jump to search
使用正規表示法 (Regular expression) ,從文章內容中擷取網址。
擷取完整網址
使用 Google 試算表 REGEXEXTRACT 函數,從文章內容擷取第一個網址。
=REGEXEXTRACT(A1, "(http[s]?://[a-zA-Z0-9\-_\\._~\:\/\?#\[\]@\!\$&'\(\)\*\+,;\=%]+)")
輸入:
Yahoo! 新聞 https://tw.news.yahoo.com/abc
輸出:
https://tw.news.yahoo.com/abc
說明:
擷取網址中的網域部分
=REGEXEXTRACT(A1, "(http[s]?\://[^/]+)")
輸入:
Yahoo! 新聞 https://tw.news.yahoo.com/abc
輸出:
https://tw.news.yahoo.com/
說明:
- 網域指 http:// 或 https:// 開頭,在符號 / 前的那一段文字。因此規則改成找不是符號 / 的多個文字。[^/]+