title: preg_replace pattern for php
body: <p>I got some problems with my patterns. Hope somebody could help me with this. </p>
  
  <p>given a string </p>
  
  <pre><code>$string = Mutualism has been retrospectively characterised as ideologically situated between individualist and collectivist forms of anarchism.&amp;lt;ref&amp;gt;Avrich, Paul. ''Anarchist Voices: An Oral History of Anarchism in America'', Princeton University Press 1996 ISBN 0-691-04494-5, p.6&amp;lt;br /&amp;gt;''Blackwell Encyclopaedia of Political Thought'', Blackwell Publishing 1991 ISBN 0-631-17944-5, p. 11.&amp;lt;/ref&amp;gt; Proudhon first characterised his goal as a &amp;quot;third form of society, the synthesis of communism and property.&amp;quot;&amp;lt;ref&amp;gt;Pierre-Joseph Proudhon. ''What Is Property?'' Princeton, MA: Benjamin R. Tucker, 1876. p. 281.&amp;lt;/ref&amp;gt; Another is &amp;lt;ref name=rupert/&amp;gt;
  </code></pre>
  
  <p>I want to remove strings inside the <code>&amp;lt;ref&amp;gt; (&lt;ref name='something'&gt;&lt;/ref&gt; or &lt;ref&gt;&lt;/ref&gt;) or remove the single ref tag &lt;ref name='sss' /&gt;</code></p>
  
  <p>after replacing the final out put should be :</p>
  
  <blockquote>
    <p>Mutualism has been retrospectively
    characterised as ideologically
    situated between individualist and
    collectivist forms of anarchism.
    Proudhon first characterised his goal
    as a "third form of society, the
    synthesis of communism and property."
    Another is</p>
  </blockquote>
  
  <p>my code doesn't seem to work</p>
  
  <pre><code>$pattern1[] = "/&amp;lt;ref[^\/]*\/&amp;gt;/is"; //remove &lt;ref name=something/&gt;  
  $pattern1[] = "/&amp;lt;ref[^\/]*&amp;gt;(.*?)&amp;lt;\/ref&amp;gt;/s";  //remove ref &lt;ref&gt;some text here&lt;/ref&gt;
  preg_replace($pattern1,"\n", $string);
  </code></pre>
  
  <p>instead it outputs :</p>
  
  <blockquote>
    <p>Mutualism has been retrospectively
    characterised as ideologically
    situated between individualist and
    collectivist forms of anarchism.
    ''Blackwell Encyclopaedia of Political
    Thought'', Blackwell Publishing 1991
    ISBN 0-631-17944-5, p. 11.&lt;/ref&gt;
    Proudhon first characterised his goal
    as a &quot;third form of society, the
    synthesis of communism and
    property.&quot;  Another is</p>
  </blockquote>
  
  <p>I guess it got caught up with the <code>&amp;lt;br /&amp;gt;</code></p>