title: Groovy: How to format output to ignore lines including "[ ]"?
body: <p>I wrote the following Groovy code:</p>
  
  <pre><code>#!/usr/local/bin/groovy
  String todayDate = new Date().format( 'yyyy-MM-dd' )
  def rdbs = "aws rds describe-db-snapshots --db-instance-identifier $dbname --snapshot-type automated --query DBSnapshots[?SnapshotCreateTime&gt;='$todayDate'].DBSnapshotIdentifier".execute().text.eachLine {
  retval.add(it.subSequence(4,it.length() ))
  }
  return retval
  </code></pre>
  
  <p>The idea is that the output will be added to an array but when I run it I get the following error:</p>
  
  <pre><code>Caught: java.lang.StringIndexOutOfBoundsException: String index out of range: -3
  java.lang.StringIndexOutOfBoundsException: String index out of range: -3
      at java_lang_CharSequence$subSequence$0.call(Unknown Source)
      at rds$_run_closure1.doCall(rds.groovy:8)
      at rds.run(rds.groovy:7)
  </code></pre>
  
  <p>So I've changed the script just to see if the output looks ok:</p>
  
  <pre><code>#!/usr/local/bin/groovy
  String todayDate = new Date().format( 'yyyy-MM-dd' )
  def dbname = 'dev-rds-2017-10-02'
  retval=[]
  def rdbs = "aws rds describe-db-snapshots --db-instance-identifier $dbname --snapshot-type automated --query DBSnapshots[?SnapshotCreateTime&gt;='$todayDate'].DBSnapshotIdentifier".execute().text 
  println rdbs
  </code></pre>
  
  <p>When I run it, I get the following proper output:</p>
  
  <pre><code>[
      "rds:dev-rds-2017-10-02-2017-11-26-00-05"
  ]
  </code></pre>
  
  <p>But I want it to return only the "rds:dev-rds-2017-10-02-2017-11-26-00-05" line, how can it be done?</p>