Your question is a bit vague. Can you give accurate information about exactly what you want to do? (Preferably with testuite.) Right now, all your questions say you want a method that always returns 'abc.google.com' . This is easy:
def extract_domain return 'abc.google.com' end
But this is probably not what you had in mind, and hellip;
Also, you say you need Regexp . What for? What is wrong, for example, with the URI class? After all, parsing and processing a URI is exactly what it was created for!
require 'uri' URI.parse('https://abc.google.com/').host
And finally, you say that you are trying to extract the domain, but you will never indicate what you mean by "domain". It looks like you sometimes mean the fully qualified domain name and sometimes randomly drop parts of the fully qualified domain name, but according to what rules? For example, for FQDN, abc.google.com the domain name google.com , and the host name is abc , but you want it to return abc.google.com , which is not only the domain name, but also the fully qualified domain name. Why?
JΓΆrg W Mittag
source share