Highlighted

GREP First Instance Only

Explorer ,
Aug 12, 2020

Copy link to clipboard

Copied

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!

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

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.

TOPICS
Scripting, Type

Views

72

Likes

Translate

Translate

Report

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

GREP First Instance Only

Explorer ,
Aug 12, 2020

Copy link to clipboard

Copied

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!

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

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.

TOPICS
Scripting, Type

Views

73

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Most Valuable Participant ,
Aug 12, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 12, 2020 2
Explorer ,
Aug 12, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 12, 2020 0