title: Groovy GString, multiple line regex - how to count number of lines?
body: <p>I just want to add something at the beginning of each line and at the end of each line:</p>
  
  <pre><code>def mystring="""
  hello
  world
  """
  matcher = (mystring =~ /(?ms)^/);
  excerpt = matcher.replaceAll("put '");
  matcher = (excerpt  =~ /(?ms)$/);
  excerpt2 = matcher.replaceAll(" ';");
  println excerpt2
  </code></pre>
  
  <p>I expected to have</p>
  
  <pre><code>  put 'hello';
    put 'world';
  </code></pre>
  
  <p>However, I got</p>
  
  <pre><code>put ' ';
  put 'hello ';
  put 'world ';
   ';
  </code></pre>
  
  <p>which means that there is a "^" after """ even there is not a real line.  Can we say that by using (?m), we have created 3 lines?  </p>
  
  <p>Thanks.</p>