title: Why can't I chain String.replace?
body: <p>I'm working on a price format function, which takes a float, and represent it properly.</p>
  
  <p>ex. 190.5, should be 190,50</p>
  
  <p>This is what i came up with</p>
  
  <pre><code>  def format_price(price) do
      price
      |&gt; to_string
      |&gt; String.replace ".", ","
      |&gt; String.replace ~r/,(\d)$/, ",\\1 0"
      |&gt; String.replace " ", ""
    end
  </code></pre>
  
  <p>If i run the following.</p>
  
  <pre><code>format_price(299.0)
  # -&gt; 299,0
  </code></pre>
  
  <p>It looks like it only ran through the first replace. Now if i change this to the following.</p>
  
  <pre><code>  def format_price(price) do
      formatted = price
      |&gt; to_string
      |&gt; String.replace ".", ","
  
      formatted = formatted
      |&gt; String.replace ~r/,(\d)$/, ",\\1 0"
  
      formatted = formatted
      |&gt; String.replace " ", ""
    end
  </code></pre>
  
  <p>Then everything seems to work just fine.</p>
  
  <pre><code>format_price(299.0)
  # -&gt; 299,00
  </code></pre>
  
  <p>Why is this?</p>