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!
Hello,
2010/4/11 Chris Watkins chriswaterguy@appropedia.org:
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".
Regarding this particular issue, you should read http://mywiki.wooledge.org/BashPitfalls#echo_.22Hello_World.21.22
Using single quotes instead of double quotes should work. Or just put "set +o histexpand" in your .bashrc ...
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
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
On Sun, Apr 11, 2010 at 19:45, Nicolas Dumazet nicdumz@gmail.com wrote:
Using single quotes instead of double quotes should work. Or just put "set +o histexpand" in your .bashrc ...
Wonderful, thank you! Making a note to myself to always do this...
pywikipedia-l@lists.wikimedia.org