Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

REGEXEXTRACT(A1:A,"(?m)http(?:s?)://.*?([^./]+?.[^.]+?)(?:/|$)")

Trying to extract domain from website

The formula above has worked for me if the link is like this: https://walmart.com/careers

However, it doesn't work if it's already a domain (walmart.com) or if it's www.walmart.com/careers

Is there a more thorough formula that can allow for these edge cases?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
718 views
Welcome To Ask or Share your Answers For Others

1 Answer

try:

=ARRAYFORMULA(INDEX(SPLIT(REGEXREPLACE(A8:A12, "https?://www.|https?://|www.", ), "/"),,1))

0

enter image description here


UPDATE 1:

=ARRAYFORMULA(IFNA(REGEXEXTRACT(INDEX(SPLIT(
 REGEXREPLACE(A8:A14, "https?://www.|https?://|www.", ), "/"),,1), 
 ".(.+..+)"), INDEX(SPLIT(
 REGEXREPLACE(A8:A14, "https?://www.|https?://|www.", ), "/"),,1)))

0


UPDATE 2:

=INDEX(IFERROR(REGEXEXTRACT(A1:A, "^(?:https?://)?(?:ftp://)?(?:www.)?([^/]+)")))

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...