Skip to main content
Participant
August 24, 2022
Question

Grep Query

  • August 24, 2022
  • 2 replies
  • 375 views

Hello,
I'm working on a long document. There are lots of paragraphs which start with first word ALL CAPS. So I want to apply a paragraph style to all those paragraphs at once. So the problem is, I want to find and replace only the paragraphs which first word is ALL CAPS. Then I can apply the paragraph style to it. Anyone can help to find a Grep for this? 

Attached a screenshot to get things clear. Please tell me if I didn't explained it clearly.

 

This topic has been closed for replies.

2 replies

Barb Binder
Community Expert
Community Expert
August 24, 2022

Very true.

 

So, if the text at the beginning of a paragraph was typed using actual uppercase letters, use a GREP search for:

^\u+

 

If the type is upper and lowercase, but formatted with the All Caps command use a Text search for text formatted as All Caps:

~Barb

~Barb at Rocky Mountain Training
Peter Spier
Community Expert
Community Expert
August 25, 2022

You still need to be sure you're finding text at the start of the paragraph, though, and that first letter would have been typed as upper case and may or may not have all caps applied.

(?<=^\u)\l seems to find the string correctly up until I add the All Caps formatting at which point I get a Cannot find match error because the first letter is not styled as All Caps.

I suspect that if the first character in the paragraph is plain typed upper case and not styled as All Caps it is not possible to find the first word in the paragraph in all caps using Find/Change. I'd love it if one of the GREP ninjas could tell me I'm wrong and show us how it's done.

Peter Spier
Community Expert
Community Expert
August 25, 2022

I don't write scripts, but I have every confidence that this could be scripted by checking the second character in a paragraph to see if All Caps is applied and if is true assign the paragraph style.

Peter Spier
Community Expert
Community Expert
August 24, 2022

It makes a difference if the All Caps were keyed that way with the shift lock on or if they were applied to lowercase letters.