title: Java replace only first occurrence of a substring in a string
body: <p>This is somehow a duplicate of this problem <a href="https://stackoverflow.com/questions/7963394/ruby-replace-the-first-occurrence-of-a-substring-with-another-string">Ruby - replace the first occurrence of a substring with another string</a> just in java.</p>
  
  <p>Problem is:</p>
  
  <p>I have a string: <code>"ha bla ha ha"</code></p>
  
  <p>Now I want to replace the first (and only the first) <code>"ha"</code> with <code>"gurp"</code>:</p>
  
  <pre><code>"gurp bla ha ha"
  </code></pre>
  
  <p><code>string.replace("ha", "gurp")</code> doesn't work, as it replaces all <code>"ha"</code>s.</p>