Skip to main content
cbks2019
Participant
July 5, 2023
Answered

GREP Operation to Remove Return within Item Paragraph while Maintaining Return Between Items

  • July 5, 2023
  • 1 reply
  • 311 views

Hello,

 

I have a document that is structured in the following way:

 

A0. Item A0 text.... ending with a period.

A1. Item A1 text.... ending with a period.

B1. etc.

...

 

In parts of this document, the item's paragraph has a return within it such that the following occurs:

 

C933. Item C933 text... \r

text continues as new paragraph (break may occur between words, numbers, following puncuation, etc.).

C934. Item C934 text...   .

C935. etc.

 

I am trying to figure out a GREP script that will remove any return within an item's paragraph. The GREP script would ensure that if a period followed by a return, followed by any sequence of 1 letter and 1 or more numbers followed by a period as seen here:

C934. Item C934 text...   .\r

C935. etc.

 

would be maintained; however, if the following occurs

 

C933. Item C933 text... \r

continues as new paragraph.

C934. Item C934 text...   .

 

the script would remove the return such that the above would appear as follows:

 

C933. Item C933 text continues in same paragraph.

C934. Item C934 text...   .

 

Thank you very much for any help you may be able to provide.

 

This topic has been closed for replies.
Correct answer FRIdNGE

Find: (^\D\d+\.\h).+\K\r(?!(?1))

Replace by a simple common space

 

(^/)  The Jedi

1 reply

FRIdNGE
FRIdNGECorrect answer
July 5, 2023

Find: (^\D\d+\.\h).+\K\r(?!(?1))

Replace by a simple common space

 

(^/)  The Jedi

cbks2019
cbks2019Author
Participant
July 5, 2023

Thank you FRIdNGE for your help - this was the answer!