title: Fetch the values from a string with regular expression in bash
body: <p>I have a string and I want to extract the needed values from this string, so I wrote some regex patterns, I searched in google and I find I have to use <code>echo</code> command and then store in a variable.</p>
  
  <p>I tested my regex pattern with regex101.com and the pattern is correct but I don't know why not work in bash script.</p>
  
  <p>this is my code:</p>
  
  <pre><code>output="VPC created: vpc-something
  Security Group created: sg-something
  Subnet created: subnet-something1
  Subnet created: subnet-something2
  Cluster creation succeeded."
  
  
  regex1="/(VPC\screated:)\s+(.*)$/gm"
  regex2="/(Subnet\screated:)\s+(.*)$/gm"
  
  vpc=$(echo $output| grep -q $regex1)
  subnet=$(echo $output| grep -q $regex2)
  
  echo $vpc
  echo $subnet
  </code></pre>
  
  <p>the output of this code is nothing</p>