title: Java Regex: How to extract ip address except the last part from the string?
body: <p>I am experimenting with <code>websockets</code> and I want to make it connect to local network automatically from another computer on the <code>LAN</code> and since there are 255 possible computers on the same network I want it to try all and then connect to whichever it can connect to first. However, first part of an IP address, <strong>192.168.1.*</strong>, is different based on router settings.</p>
  
  <p>I can get the whole current IP address of the machine, then I want to extract the front part.</p>
  
  <p>For example</p>
  
  <pre><code>25.0.0.5 will become 25.0.0.
  192.168.0.156 will become 192.168.0.
  192.168.1.5 will become 192.168.1.
  </code></pre>
  
  <p>and so on</p>
  
  <pre><code> String Ip  = "123.345.67.1";
   //what do I do here to get IP == "123.345.67."
  </code></pre>