title: compare string with Regular Expressions in if statement
body: <p>I have file <code>test.txt</code></p>
  
  <pre><code>class c1 {
      ___________ any text _____________
  }
  class c2 {
      ___________ any text _____________
  }
  class c3 {
      ___________ any text _____________
  }
  </code></pre>
  
  <p>I write bash script to scan <code>test.txt</code> line by line and compare each line with regular expressions to get the lines that contain the header of class but not work :(</p>
  
  <pre><code>#!/bin/bash
  while read line           
  do           
      if [[ "$line" =~ "class *\w+" ]]; then
          echo $line
      fi  
  done &lt;test.txt
  </code></pre>
  
  <p>The final goal separate each class in file </p>