title: php sed like functionality
body: <p>I am quite familiar with sed on bash shell, so I do  </p>
  
  <pre><code>cat $myfile | egrep $pattern | sed -e 's/$pattern/$replace/g'
  </code></pre>
  
  <p>a lot. Quite a few times, I find that I need to do similar kind of "string parsing" inside PHP.  </p>
  
  <p>So my question is simple, what is the equivalent of <code>sed -e 's/$pattern/$replace/g'</code> in PHP ?  </p>
  
  <p>I know preg_match , preg_replace , but I haven't used them / not at all familiar with them. I would really appreciate sample code in PHP. (converting say a <code>$var = '_myString'</code> to <code>$newVar = 'getMyString'</code> )</p>