Regex for remove domain in hostname : <p>I am trying to capture only the hostname within this date, but my regex is broken when inside the hostname, there are <code>.</code> because I remove the <strong>hostname domain</strong></p>

<p><strong>REGEX</strong></p>

<pre><code>^([^;@#.\s]+)
</code></pre>

<p><strong>DATA</strong></p>

<pre><code>srvdata;172.24.154.210
srvnet;10.16.0.1
srvdata2 300
#srvdata3
srvdata3 #srvdata3
srvdata4.domain.com
srvdata.4.domain.com
</code></pre>

<p><strong>OUTPUT</strong></p>

<pre><code>srvdata
srvnet
srvdata2
srvdata3
srvdata4
srvdata
</code></pre>

<p><strong>DESIRED OUTPUT</strong></p>

<pre><code>srvdata
srvnet
srvdata2
srvdata3
srvdata4
srvdata.4
</code></pre>

<p><a href="https://regex101.com/r/KQNbSr/3/" rel="nofollow noreferrer"><strong>REGEX101</strong></a></p>
