title: replaceFirst does not work, but replace works on the exact same input?
body: <p>I am writing a program where a portion of it needs to replace part of the string without deleting duplicates so I am using replaceFirst() which is not working properly. </p>
  
  <p>INPUT:</p>
  
  <pre><code>lock: "O_2_^-^"
  str:  " O_2_^-^ " 
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>System.out.println(str);
  System.out.println(lock);
  System.out.println(str.contains(lock));
  str = str.replaceFirst(lock, "");
  System.out.println(str);
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code> O_2_^-^ 
  O_2_^-^
  true
   O_2_^-^ 
  </code></pre>
  
  <p>The above is real output from my program. Though the replace() method will not work for my current situation I did test it and the output is compeletely different, as in correct.</p>
  
  <p>INPUT:</p>
  
  <pre><code>lock: "O_2_^-^"
  str:  " O_2_^-^ " 
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>System.out.println(str);
  System.out.println(lock);
  System.out.println(str.contains(lock));
  str = str.replace(lock, "");
  System.out.println(str);
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code> O_2_^-^ 
  O_2_^-^
  true
    //empty line of output because string was detected and removed.
  </code></pre>
  
  <p>I have tried everything outside of writing my own replaceFirst() method, if anyone has any advice or input that'd be great. Thanks!</p>