small regexp help

rusi rustompmody at gmail.com
Wed Oct 30 12:56:49 EDT 2013


Well it seems that we are considerably closer to a solution to the GG double-spaced crap problem.

Just wondering if someone can suggest a cleanup of the regexp part

Currently I have (elisp)

(defun clean-gg () 
  (interactive)
1  (replace-regexp "^> *\n> *\n> *$" "-=\=-" nil 0 (point-max))
2  (flush-lines "> *$" 0 (point-max))
3  (replace-regexp "-=\=-" "" nil 0 (point-max)))

Which I spell out as:

1. Replace triplets of empty lines of the form

>
>
>

with only 1 (because this is an actual blank line and not a GG-crap line)
However then it gets mixed up with the others so put some strange string:
"-=\=-" as replacement

2. Remove the pure
> 
lines

3. Remove the strange string.

Not very robust since the strange string could occur in the text.
So what are the more proper regexp solution(s)?



More information about the Python-list mailing list