[Pywikipedia-l] Regex for headers without line breaks.

Chris Watkins chriswaterguy at appropedia.org
Sun Apr 11 07:51:10 UTC 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/pywikipedia-l/attachments/20100411/70d2f8a7/attachment.htm 


More information about the Pywikipedia-l mailing list