title: How to extract substring in Groovy?
body: <p>I have a Groovy method that currently works but is <em>real</em> ugly/hacky looking:</p>
  
  <pre><code>def parseId(String str) {
      System.out.println("str: " + str)
      int index = href.indexOf("repositoryId")
      System.out.println("index: " + index)
      int repoIndex = index + 13
      System.out.println("repoIndex" + repoIndex)
      String repoId = href.substring(repoIndex)
      System.out.println("repoId is: " + repoId)
  }
  </code></pre>
  
  <p>When this runs, you might get output like:</p>
  
  <pre><code>str: wsodk3oke30d30kdl4kof94j93jr94f3kd03k043k?planKey=si23j383&amp;repositoryId=31850514
  index: 59
  repoIndex: 72
  repoId is: 31850514
  </code></pre>
  
  <p>As you can see, I'm simply interested in obtaining the <code>repositoryId</code> value (everything after the <code>=</code> operator) out of the String. Is there a more efficient/Groovier way of doing this or this the only way?</p>