This is as more about the learning process than the actual task... but I can't see what's wrong with my regex, and I'd appreciate any pointers.

I want to find cases where a header is not followed by a line break, e.g.

"== External links ==;http://www.americanbamboo.org/GeneralInfo.html

I tried various regex strings, including   "([\r\n]==[^\n=]*==)([^=\r ])"   (allowing for the fact that excess spaces on the end aren't important)  to be replaced by     "\\1\n\\2"

But I get many false matches. See http://www.pastie.org/913753 for details of the good and the false matches.


In #regex on freenode I was told to try: "s/((={2,}).*?\2)(?!\n)([^=]?)/\1\n\2/g" but it gives the error: "bash: !\n: event not found".

I'm told that it works - http://pastie.org/913765 - but in my terminal I can't get past the bash error.


Thanks!

--
Chris Watkins

Appropedia.org - Sharing knowledge to build rich, sustainable lives.

blogs.appropedia.org
community.livejournal.com/appropedia
identi.ca/appropedia
twitter.com/appropedia