{"id":2863,"date":"2006-09-24T15:05:13","date_gmt":"2006-09-24T19:05:13","guid":{"rendered":"http:\/\/www.drunkenfist.com\/304\/2006\/09\/24\/javascript-parse-domain-name-out-of-a-string\/"},"modified":"2014-10-08T16:49:49","modified_gmt":"2014-10-08T20:49:49","slug":"javascript-parse-domain-name-out-of-a-string","status":"publish","type":"post","link":"https:\/\/htmlcssjavascript.com\/javascript\/javascript-parse-domain-name-out-of-a-string\/","title":{"rendered":"Javascript: Parse Domain Name out of a String"},"content":{"rendered":"<p>Did I mention that the &#8220;Web&#8221; category might contain code? It might. In fact, it will.<\/p>\n<p>Here&#8217;s a random function I wrote last night that might be useful<\/p>\n<p><code><br \/>\nfunction getDomain (thestring) {<br \/>\n\/\/simple function that matches the beginning of a URL<br \/>\n\/\/in a string and then returns the domain.<br \/>\nvar urlpattern = new RegExp(\"(http|ftp|https):\/\/(.*?)\/.*$\");<br \/>\nvar parsedurl = thestring.match(urlpattern);<br \/>\nreturn parsedurl[2];<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Is there a better way to do that? <em>I don&#8217;t know<\/em>. The momentum of &#8220;I&#8217;ve got to get this done&#8221;, got in the way and left me with the above function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did I mention that the &#8220;Web&#8221; category might contain code? It might. In fact, it will. Here&#8217;s a random function I wrote last night that might be useful function getDomain (thestring) { \/\/simple function that matches the beginning of a URL \/\/in a string and then returns the domain. var urlpattern = new RegExp(&#8220;(http|ftp|https):\/\/(.*?)\/.*$&#8221;); var [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2863","post","type-post","status-publish","format-standard","hentry","category-javascript"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3uLY6-Kb","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/posts\/2863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/comments?post=2863"}],"version-history":[{"count":0,"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/posts\/2863\/revisions"}],"wp:attachment":[{"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/media?parent=2863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/categories?post=2863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/htmlcssjavascript.com\/wp-json\/wp\/v2\/tags?post=2863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}