This is as more about the learning process than the actual task... but I can&#39;t see what&#39;s wrong with my regex, and I&#39;d appreciate any pointers.<br><br>I want to find cases where a header is not followed by a line break, e.g. <br>

<br><div style="margin-left: 40px;">&quot;== External links ==;<a href="http://www.americanbamboo.org/GeneralInfo.html">http://www.americanbamboo.org/GeneralInfo.html</a><br></div><br>I tried various regex strings, including   &quot;([\r\n]==[^\n=]*==)([^=\r ])&quot;   (allowing for the fact that excess spaces on the end aren&#39;t important)  to be replaced by     &quot;\\1\n\\2&quot;<br>

<br>But I get many false matches. See <a href="http://www.pastie.org/913753">http://www.pastie.org/913753</a> for details of the good and the false matches.<br><br><br>In #regex on freenode I was told to try: &quot;<span>s/((={2,}).*?\2)(?!\n)([^=]?)/\1\n\2/g&quot; but it gives the error:</span><span> &quot;bash: !\n: event not found&quot;</span>.<br>

<br>I&#39;m told that it works - <a href="http://pastie.org/913765">http://pastie.org/913765</a> - but in my terminal I can&#39;t get past the bash error.<br><br><br>Thanks!<br><br>-- <br>Chris Watkins<br><br>Appropedia.org - Sharing knowledge to build rich, sustainable lives.<br>

<br><a href="http://blogs.appropedia.org">blogs.appropedia.org</a><br><a href="http://community.livejournal.com/appropedia">community.livejournal.com/appropedia</a><br><a href="http://identi.ca/appropedia">identi.ca/appropedia</a><br>

<a href="http://twitter.com/appropedia">twitter.com/appropedia</a><br>