title: Regex - validate IPv6 shell script
body: <p>I am able to validate IPv6 addresses using java with following regex:</p>
  
  <p><code>([0-9a-fA-F]{0,4}:){1,7}([0-9a-fA-F]){0,4}</code></p>
  
  <p>But I need to do this in shell script to which I am new.</p>
  
  <p>This regex doesn't seem to work in shell. Have tried some other combinations also but nothing helped.</p>
  
  <pre><code>#!/bin/bash
  regex="([0-9a-fA-F]{0,4}:){1,7}([0-9a-fA-F]){0,4}"
  var="$1"
  
  if [[ "$var" =~ "$regex" ]]
  then
          echo "matches"
  else
          echo "doesn't match!"
  fi
  </code></pre>
  
  <p>It gives output <strong>doesn't match!</strong> for <strong>2001:0Db8:85a3:0000:0000:8a2e:0370:7334</strong></p>
  
  <p>How can I write this in shell script?</p>