title: Javascript Regular Expression to PHP
body: <p>I have written this JavaScript that calculate words, but I am unable to convert this JavaScript code to PHP regular expression. Can anyone help me with following code?</p>
  
  <pre><code>return str.replace(/\&amp;\w+;/ig,"")
          .replace(/lt;/g, "&lt;")
          .replace(/gt;/g, "&gt;")
          .replace(/(&lt;([^&gt;]+)&gt;)/ig,"")
          .replace(/^[^A-Za-z0-9-\']+/gi, "")
          .replace(/[^A-Za-z0-9-\']+/gi, " ")
          .split(" ")
          .length - 1;
  </code></pre>