I have grabbed some urls from Google search results using a regular expression. It has provided me the links in the format given below. Now, I just want the scheme and the host.
Regex to match the above mentioned URL's which are preceded by /url?q= ,
/url?q=
\/url\?q=\K.*?(?=\/&)
DEMO
OR
www\.[^.]*\.(?:org|com)
Your PHP code would be,
Output:
array(1) { [0]=> array(2) { [0]=> string(28) "http://www.fertile-focus.com" [1]=> string(24) "http://www.genetests.org" } }