Skip to main content
Known Participant
March 1, 2022
Answered

In GREP, how to find a line of text, starting with a specific word and ending with a paragraph mark

  • March 1, 2022
  • 3 replies
  • 2281 views

I'm trying to find a line of text that starts with a specific word plus a colon and ends with a paragraph mark. I played around with some wild cards and/or positive look behind but clearly am not adept enough at these kind of seraches to figure this out. Here's an example of the specific text I want to find:

 

        Statute: Section 1202. State Certificates.

 

Every line starts with "Statute: " and ends with a paragraph mark (return). FYI, after I find this type of line, I want to change its Paragraph style, which I know how to do.

 

 

This topic has been closed for replies.
Correct answer SJRiegel

Actually, I do have other instances where the answer is YES, so I'm definitely interested in your response to this! I know I could put a \r in front of it to find only the instances where it's on its own line, but then the change Para Style would apply to the previous para, right?

 

FYI, In this case, a sample stand-alone line I am looking for would be:

 

     § 49.143. Vocational Instructional II.

 

The would always start with "§ ". But there are numerous cases where "§ " appears in the middle of a para, which I would not want to find.


As long as the ones you don't want to find are not at the beginning of a paragraph, this should work. It finds your text when it occurs at the beginning of a paragraph.

 

^~6 \d+\.\d+\. .+

 

3 replies

pixxxelschubser
Community Expert
Community Expert
March 1, 2022

^§\h[0-9.]+\h.+

Legend
March 1, 2022

Are there instances where this pattern appears mid-paragraph, and if so, are those instances not intended to change to the new paragraph style?

Known Participant
March 1, 2022

Good question. I'm pretty sure the answer is no. And jmlevy's answer, above, worked for me.

But, just for my edification, if I'd said yes, do you have a suggestion?

SJRiegelCorrect answer
Legend
March 1, 2022

Actually, I do have other instances where the answer is YES, so I'm definitely interested in your response to this! I know I could put a \r in front of it to find only the instances where it's on its own line, but then the change Para Style would apply to the previous para, right?

 

FYI, In this case, a sample stand-alone line I am looking for would be:

 

     § 49.143. Vocational Instructional II.

 

The would always start with "§ ". But there are numerous cases where "§ " appears in the middle of a para, which I would not want to find.


As long as the ones you don't want to find are not at the beginning of a paragraph, this should work. It finds your text when it occurs at the beginning of a paragraph.

 

^~6 \d+\.\d+\. .+

 

jmlevy
Community Expert
Community Expert
March 1, 2022

This should work:

 

Statute:.+\r

 

Known Participant
March 1, 2022

It does!!!! (I was making it too complicated, I guess.)

Thanks so much.