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!
1 Correct answer
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.
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.
Copy link to clipboard
Copied
Thank you! Worked like a charm; I was putting the ? AFTER the colon, and also escaping the colon..
Copy link to clipboard
Copied
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:
Is there any solution to search for "OVERVIEW:", but replacing it with "OVERVIEW[new paragraph]" = not with the colon?
THANKS!
mycc
Copy link to clipboard
Copied
Try this:
find:(.+?):

