I've been using GREP more and more for styling text and I really love it. In most cases I have been able to figure out how to write expressions to do what I need, but right now this one escapes me. I want to apply a character style to lines of text that DO NOT contain a colon. I've tried a few different things but can't quite get it to work. The closest I have come is to get the style applied to single-word lines using this code that employs a negative lookahead:

^(\w+)(?!\:)$

But, what I REALLY need is for the (\w+) to instead be something that represents a string of ANY characters (number or letter or hyphen in my case) that does not end with a colon. But if I write something like:

^.*(?!\:)$

It just applies the style to everything. I need to be able to exclude lines of text that do not end with a colon.

Here is an snippet of text that I am trying to style. So in the case below, I only want the lines "3-Point Field Goals" and "Team Points" to have the character style applied. (There is already a different GREP style in the works that will bold the beginning of the other lines through the first colon.)

Maybe this is a better job for a Nested Style and not a GREP style. I created a paragraph style with a nested style that applies bold through 1 colon and applied it to everything. If the line doesn't contain a colon, it applies it to the entire line. If it does have a colon, it only applies bold through the 1st colon in the paragraph. See screen shot below.

Thank you for your reply. Unfortunately I didn't mention that the style being applied to these other lines is not just bold..... it's different in other ways as well (unique case, character color, and leading).... so I really need to be able to be more specific.

You can use Nested styles in conjunction with GREP styles. As a matter of fact GREP styles take priority over Nested styles so you should be able to add your GREP expression to the paragraph style definition as well to achieve the desired result.

I understand that. I use GREP in conjunction with Nested styles a lot. What I'm getting at is, I need someone to help me construct exactly the correct expression that will single out lines of text that do not end in a colon. Application of GREP is not the problem. Discovering the exact expression that will find the pattern I want to single out is my issue. I've been researching it and am unable to find an expression that basically says "find a line of text that does not contain this specific character." Part of the problem is that there is GREP that people employ in the "real world" and then there is GREP that is specifically applied within InDesign. Some of the "real world" GREP expressions do not translate or work exactly the same within INDD. I have found snippets here and there in "real world" that show me how to match a negative instance of something (for lack of a better term) but I cannot seem to get it just right so that it works in INDD. There are things like applying {0} to a character to tell it to match zero times, and I've also seen reference to using expressions like a -v and "awk" and all sorts of random things. So far I have not been able to write any of these things out in such a way that it will work for me. Unfortunately, I don't have a ton of time to research all these code-related things when I am under deadline. That's why I was hoping perhaps someone in this forum might be familiar enough with writing GREP that they could help me construct the little snippet of code that I need.

You keep saying lines, and you cannot use grep to distinguish the end of a line unless it also has a break of some sort at the end of the line. If you want identify a paragraph that does not end in a colon you could use [^:]$ (that's a negative class that includes everything that is NOT a colon), or (?<!\:)\r (but this one will not find the last paragraph in a story unless it also ends in a return).

Sorry. The problem is that other lines of text within the main paragraph style contain colons (within the text, not at the end of the line/string). Is there a way to "negative match" a string that contains a colon anywhere within it? Basically if there is a colon anywhere in the string, I need it to ignore that string. If I tell it to find strings that don't end in a colon, it will actually find everything.

Well, what Peter was trying to explain in post #5 is that GREP can't "see" where a "line" (or what you're now calling a 'string') begins or ends, and so of course it can't guess how to qualify whether there is a colon included within. There has to be something to mark the beginning and the end of a found "string."

I actually DO understand that. What I'm looking for is how to "negative match" (for lack of a better term) a colon. Can everyone please extend me a little grace for the fact that I don't know all the exact, correct lingo?

Let me start again. here is an example of text I need to style (in reality, I have many pages of similar text). The same paragraph style is applied to ALL of it. I want to use GREP to apply a specific, unique character style that I have set up to ONLY the lines that do not contain a colon.

So, if I understand what you are saying now, you want to find only paragraphs that contain no colons at all, not that don't end with a colon. That would be ^[^:]+$ which requires every character from the beginning to end of the paragraph to be a member of the not a colon class. In your sample above it would match only 3-point Field Goals and Team Points.

Peter... yes, you understand what I am saying, thank you and I apologize for not being crystal clear before. However, the expression you suggested does not work for some reason (I tested it). It would work for the find/change just fine... I just wanted to do it the other way, in this instance. I guess I'm going to have to apply a separate paragraph style instead of achieving it through a single, more complex style that is applied to everything.

Your second expression is the same as the one I posted above, so I know it works, and I tried the first one and it works too, but for the life of me I don't understand why. How can you include not a return and still match to the end of a paragraph?