title: Regular expression to extract hostname from fully qualified domain name
body: <p>I am VERY rusty with regular expressions and need one to extract a hostname from a fully qualified domain name (FQDN), here's an example of what I have:</p>
  
  <pre><code>myhostname.somewhere.env.com
  myotherhostname.somewhereelse.insomeotherplace.byh.info
  </code></pre>
  
  <p>and I want to return</p>
  
  <pre><code>myhostname
  myotherhostname
  </code></pre>
  
  <p>Would really appreciate some help</p>
  
  <p>I tried <code>"(.+)\."</code> but it matched the string from the right and produced:</p>
  
  <pre><code>myhostname.somewhere.env.
  myotherhostname.somewhereelse.insomeotherplace.byh.
  </code></pre>