Stripping unwanted returns
Posted: Thu May 31, 2007 12:35 pm
Hi there,
I'm trying to code a routine which will deal with the extra return characters in text which is copy/pasted from an email. Email programs usually hard-wrap text at about 80 characters. I can assume that a single return which is not followed by whitespace or another return is a hardwrap that should be removed, so that in this text:
This is
a paragraph.
This is a
second paragraph.
This is a third paragraph.
The first and third linebreaks can be removed.
This is easy to do with plain text, but I'm not sure how to approach it in the context of a TRichViewEdit, since each line will be a "paragraph"; I guess what I need to do is to find any paragraph which:
-is not empty
-does not start with whitespace, and
-is not preceded by an empty paragraph
and then "merge" it with the preceding paragraph. Has anyone done anything like this before with TRichViewEdit, and if so, can you suggest an approach?
All help appreciated,
Martin
I'm trying to code a routine which will deal with the extra return characters in text which is copy/pasted from an email. Email programs usually hard-wrap text at about 80 characters. I can assume that a single return which is not followed by whitespace or another return is a hardwrap that should be removed, so that in this text:
This is
a paragraph.
This is a
second paragraph.
This is a third paragraph.
The first and third linebreaks can be removed.
This is easy to do with plain text, but I'm not sure how to approach it in the context of a TRichViewEdit, since each line will be a "paragraph"; I guess what I need to do is to find any paragraph which:
-is not empty
-does not start with whitespace, and
-is not preceded by an empty paragraph
and then "merge" it with the preceding paragraph. Has anyone done anything like this before with TRichViewEdit, and if so, can you suggest an approach?
All help appreciated,
Martin