title: How to trim <br>, spaces and &nbsp from start and end of string
body: <p>I'm trying to combine trimming of <code>&lt;br&gt;</code> or <code>&lt;br /&gt;</code>, whitespaces and <code>&amp;nbsp;</code>'s from the start and end of a string.</p>
  
  <p>There are a few similar questions (<a href="https://stackoverflow.com/questions/7360447/trim-nbsp-and-br-tags-from-string-java-or-javascript">here</a> and <a href="https://stackoverflow.com/questions/10603527/how-to-remove-trailing-white-spaces-and-nbsp-from-the-start-and-end-of-a-str">here</a>), but I couldn't get all 3 working in PHP.</p>
  
  <p>Currently I have this; <code>#(^(&amp;nbsp;|\s)+|(&amp;nbsp;|\s)+$)#</code> needing combining with this: <code>/(^)?(&lt;br\s*\/?&gt;\s*)+$/</code> but have no idea how to accomplish it. I'm using a PHP preg_replace.</p>
  
  <p>Any help would be great, thanks.</p>