small regexp help
jianbing.tai at gmail.com
jianbing.tai at gmail.com
Thu Oct 31 00:04:32 EDT 2013
On Thursday, October 31, 2013 12:56:49 AM UTC+8, rusi wrote:
> 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)?
Why not replace the triple "> " with blank directly?
maybe looks like: (replace-regexp "^> *\n> *\n> *$" "" nil 0 (point-max)
(Not fully sure whether your replace-regex could work with such format.)
PS: this is python group, assume your question better post on Lisp or Regular Expression related groups.
More information about the Python-list
mailing list