title: Remove links with hash symbol from string
body: <p>I have a database with HTML content and it has some text with links. Some texts have hash symbol in their URLs, some others no.</p>
  
  <p>I need to delete the links with hash symbol, keeping those with <strong>no</strong> hash symbol on it. </p>
  
  <p><strong>Example:</strong></p>
  
  <p>Input:</p>
  
  <pre><code>&lt;a href="http://example.com/books/1"&gt;The Lord of the Rings&lt;/a&gt;
  &lt;ul&gt;
      &lt;li&gt;&lt;a   href="http://example.com/books/1#c1" &gt;Chapter 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a name="name before href" href="http://example.com/books/1#c2"&gt;Chapter 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/1#c3" name="name after href"&gt;Chapter 3&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/1#cN" target="_blank"&gt;Chapter N&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;a href="http://example.com/books/1"&gt;Harry Potter&lt;/a&gt;
  &lt;ul&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/2#c1" target="_self"&gt;Chapter 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/2#c2" name="some have name" title="some others have title" &gt;Chapter 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/2#c3"&gt;Chapter 3&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://example.com/books/2#cN"  &gt;Chapter N&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>&lt;a href="http://example.com/books/1"&gt;The Lord of the Rings&lt;/a&gt;
  &lt;ul&gt;
      &lt;li&gt;Chapter 1&lt;/li&gt;
      &lt;li&gt;Chapter 2&lt;/li&gt;
      &lt;li&gt;Chapter 3&lt;/li&gt;
      &lt;li&gt;Chapter N&lt;/li&gt;
  &lt;/ul&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;a href="http://example.com/books/2"&gt;Harry Potter&lt;/a&gt;
  &lt;ul&gt;
      &lt;li&gt;Chapter 1&lt;/li&gt;
      &lt;li&gt;Chapter 2&lt;/li&gt;
      &lt;li&gt;Chapter 3&lt;/li&gt;
      &lt;li&gt;Chapter N&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I am trying with this code, but it delete all the links and I want to keep those with no hash symbol.</p>
  
  <pre><code>$content = preg_replace('#&lt;a.*?&gt;([^&gt;]*)&lt;/a&gt;#i', '$1', $content);
  </code></pre>
  
  <p>So, currently I am getting this:</p>
  
  <pre><code>The Lord of the Rings
  &lt;ul&gt;
      &lt;li&gt;Chapter 1&lt;/li&gt;
      &lt;li&gt;Chapter 2&lt;/li&gt;
      &lt;li&gt;Chapter 3&lt;/li&gt;
      &lt;li&gt;Chapter N&lt;/li&gt;
  &lt;/ul&gt;
  &lt;br&gt;&lt;br&gt;
  Harry Potter
  &lt;ul&gt;
      &lt;li&gt;Chapter 1&lt;/li&gt;
      &lt;li&gt;Chapter 2&lt;/li&gt;
      &lt;li&gt;Chapter 3&lt;/li&gt;
      &lt;li&gt;Chapter N&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>More details:</p>
  
  <ul>
  <li>I am using PHP.</li>
  <li>The only reference I have to know what links to delete is de # symbol.</li>
  <li>Some links have new line.</li>
  </ul>
  
  <p>Example:</p>
  
  <pre><code>&lt;a href="http://example.com"&gt;
      new line&lt;/a&gt;
  or
  &lt;a href="http://example.com"&gt;new
      line&lt;/a&gt;
  </code></pre>