 <p>You can do this without regex using <code>awk</code> (on this simple example):</p> <pre><code>awk -F":|/" '{print $2}' file 192.1.1.128 192.1.1.11 </code></pre> <hr> <p>To test if its IP contains three <code>.</code>:</p> <pre><code>awk -F":|/" '{n=split($2,a,".");if (n=4) print $2}' file 192.1.1.128 192.1.1.11 </code></pre>