Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

GREP First Instance Only

Explorer ,
Aug 12, 2020 Aug 12, 2020

I have a large directory I'm trying to format. Each entry has a list of items followed by a descriptive paragraph. Each item in the list has a label followed by a colon. I want to style the label along with the colon, making them bold and all-caps. I had success with the following expression:

.+\:

Which ends up like this:

PHONE NUMBER: 123-456-7890

WEBSITE: www.adobe.com

The problem is, that occasionally one of the descriptive paragraphs will also have a colon, resulting in this:

OVERVIEW: THIS TEXT SHOULD NOT BE STYLED: and should return to normal after only the first colon.

I've been trying various expressions to get it to work and either I get all the text styled, none of the text styled or the above problem. Any help is appreciated! Thank you!

TOPICS
Scripting , Type
4.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 12, 2020 Aug 12, 2020

GREP is greedy by default; it tries to match as much as possible. Make your expression non-greedy by adding a question mark:

 

^.+?:

 

or use a nested style "Up to" and then type a colon.

Translate
Community Expert ,
Aug 12, 2020 Aug 12, 2020

GREP is greedy by default; it tries to match as much as possible. Make your expression non-greedy by adding a question mark:

 

^.+?:

 

or use a nested style "Up to" and then type a colon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2020 Aug 12, 2020

Thank you! Worked like a charm; I was putting the ? AFTER the colon, and also escaping the colon..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2021 Apr 18, 2021

Similar case. But I want to get the found string without the colon.

If I would use following term it would be the same problem, it will become greedy:


Searching for:

(.+)?:

Replacing with (formatted): 

$1\r

 

That's the result:

mycc_0-1618790771508.pngexpand image

Is there any solution to search for "OVERVIEW:", but replacing it with "OVERVIEW[new paragraph]" = not with the colon?

 

THANKS!

mycc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 18, 2021 Apr 18, 2021
LATEST

Try this:

 

find:(.+?):

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines