small regexp help

R

rusi

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 purelines

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)?
 
J

jianbing.tai

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top