title: php regular expressions for substring start with A, end with B in order to remove the A and B
body: <p>I want to use regular expressions to find a substring that start with A and end with B and remove the A and B.</p>
  
  <p>For example change <code>xxxxAmmmm(andMoreContentHere)Bvv</code> to </p>
  
  <p><code>xxxxmmmm(and something more)vv</code>.</p>
  
  <p>This is what I come up with  <code>'/(A([^B]*)B)/i'</code>;</p>
  
  <p>But using <code>preg_replace('/(A([^B]*)B)/i', '', $string)</code> will give me <code>xxxxvv</code> unless I specify <code>mmmm(andMoreContentHere)</code> but <code>(andMoreContentHere)</code> is user-generated content. So what should I do to only remove A and B?</p>