title: replace string contained between two characters
body: <p>I have a string like:</p>
  
  <pre><code>www.mydomain.com/product/$ID_PRODUCT$/ID_$ID_PRODUCT$
  </code></pre>
  
  <p>what I need is replace strings contained between '$' and '$', also deleting the strings delimiters ( which is '$' ) obtaining something like:</p>
  
  <pre><code>www.mydomain.com/product/1234/ID_1234
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>EDIT:
  Trying </p>
  
  <pre><code>$new_string = preg_replace('/(\$)(.*)(\$)/s', product-&gt;id, $string);
  </code></pre>
  
  <p>But it does not handle the second expression...</p>
  
  <p>The demo of @stribizhev , given in comments below, worked for me!</p>