title: What's the error with this BASH regex script?
body: <p>I'm trying to make a program that reads in <code>n</code> strings and checks them for pertaining to a regex pattern: XXXXX1234X where X is an uppercase character and {1,2,3,4} is any digit. As far as I checked, the regex pattern is correct. The problem seems to be in the input and comparison of strings.</p>
  
  <pre><code>read n
  i=0
  declare -a str
  while [ $i -lt $n ]
  do
      read 'str[$i]'
      i=$((i+1))
  done
  
  
  i=0
  while [ $i -lt $n ]
  do
  
      [[ $(str[$i])  =~ ^([A-Z]){5}([0-9]){4}([A-Z]){1}$ ]] &amp;&amp; echo YES || echo NO
      i=$((i+1))
  done
  </code></pre>