title: Regular Expression issue pattern matching
body: <p>I am trying to write a regular expression for below string pattern</p>
  
  <pre><code>String str = "&lt;name&gt;{f:&lt;one&gt;,l:&lt;two&gt;,t:&lt;three&gt;} )";
  </code></pre>
  
  <p>this pattern ends with "?" so below code works</p>
  
  <pre><code>String result = str.replaceAll(pattern, "abc");
  System.out.println(result);
  </code></pre>
  
  <p>and the output is</p>
  
  <pre><code>&lt;name&gt; ( abc abc)
  </code></pre>
  
  <p>But if the input string changes </p>
  
  <p>where next pattern doesn't end with ?, Java hung.....</p>
  
  <pre><code>String result = str.replaceAll(pattern, "abc"); 
  System.out.println(result);
  </code></pre>
  
  <p>Equivalent Scala code is</p>
  
  <pre><code>pattern.replaceAllIn(str,"abc")
  </code></pre>
  
  <p>Where am I wrong, thanks in advance</p>