Main Page / Browse Categories / Editing/Formatting / RegEx - Remove 3 or more linebreaks
RegEx - Remove 3 or more linebreaks

A user wrote:

I hope your plans include a feature to remove repeated (multiple, 3 or more in sequence) end of paragraph characters, during a "text cleanup". Of course I need two paragraph marks, one to end the paragraph, and one to provide one line space between paragraphs. In the editing work that I do, that is the single most irritating problem that I encounter, where the author puts more than two paragraph marks.

Your wish is granted! {poof!}

The RegEx Find & Replace can handle this easily. Well, it WOULD be easy if I were better at RegEx. But I figured it out.

Set as follows:

Find:  (\x0D\x0A){3,}     [x] RegEx?
Repl: \x0D\x0A\x0D\x0A    [x] RegEx?
                          [ ] Line By Line?

\x0D is a carriage return, \x0A is a linefeed, expressed in hexidecimal notation, understandable by the RegEx parser.
By placing in round braces (), that groups them together so that the iterator {} can treat as a whole. 3 means "at least 3 of these", where "these" are the preceding pattern, which is treated as a whole due to the round braces. The comma after the 3 separates min/max. Here min is 3, and max is unlimited. I could have written {3,999} instead, for example. The max is optional, but the comma isn't - otherwise it would do "only 3".
We're replacing with 2 carriage-return/linefeeds.

We're turning off the line-by-line option, so that the linebreaks are visible to the RegEx (otherwise it would not see them).

I will add this to the ClipMate help, under RegEx examples.

keywords: find replace regex linebreak removal

User Comments
RegEx - Remove 3 or more linebreaks
Add Comment
There are no user comments for this topic.
Add Comment
Additional Info
General Information
Article No. 101
Created: 01:25 PM 10.31.04
Author: Chris Thornton

No attachments.

Did this help you?
Yes No

Yes455 (45%) Voted Yes573 (55%) Voted NoNo

Other Options
Print Article
Email Article

Related Articles
How do I enter a tab in the text field of a clip?
How do I Change the title of a clip?
How do I Change the font/color/etc., of a clip?
When I paste from ClipMate, the data isn't the same as it is when doing a straight copy/paste.
Titles - how do I make the title reflect the editing?
Powered by HelpWorks Professional