fork(2) download
  1. <?php
  2. $acronym = "ASCII";
  3. $fulltext = "American Standard Code for Information Interchange";
  4. $re = "/(?s)<pre[^<]*>.*?<\\/pre>(*SKIP)(*F)|\\b$acronym\\b/";
  5. $str = "<pre>ASCII\nSometext\nMoretext</pre>More text \nASCII\nMore text<pre>More\nlines\nASCII\nlines</pre>";
  6. $subst = "<acronym title=\"$fulltext\">$acronym</acronym>";
  7. $result = preg_replace($re, $subst, $str);
  8. echo $result;
Success #stdin #stdout 0.02s 24192KB
stdin
Standard input is empty
stdout
<pre>ASCII
Sometext
Moretext</pre>More text 
<acronym title="American Standard Code for Information Interchange">ASCII</acronym>
More text<pre>More
lines
ASCII
lines</pre>