Steve (who attended my "Power through your work with InDesign Styles" seminar in September) wrote:
"I am trying to find an InDesign GREP style that would find select every character (paragraphs included) between any amount of tabs and the next instance of a bullet. Any Ideas?"
The GREP string that I came up with to do what Steve asks is this:
(?<=\t)[^~8\t]+(?=~8)
I'll take this apart and try to help you understand it piece by piece.
(?<=\t)
The \t means to look for a tab character. The (?<=) is called a "positive lookbehind," which tells InDesign to not include the thing it finds in the search result. So (?<=\t) means to "look back" for a tab character, but don't include the tab character in the search result.
[^~8\t]+
The square brackets create what is called a "character class," which means to "match any of the things in these brackets". In this case, in the brackets we have a ~8 which is a bullet, and a \t which is a tab character. So [~8\t] would mean to match any character that is a bullet or tab. But if you look closely, we have a ^ before the bullet in the character class. This means "not". So [^~8\t] means to match any character that is NOT a bullet or tab.
Finally, you'll notice a + after the character class. This means to match the character class "one or more times". So [^~8\t]+ means to match "one or more characters that are not bullet or tab characters".
(?=~8)
As we saw above, the ~8 is a bullet character. The (?=) is a "positive lookahead," which, like a "positive lookbehind" tells InDesign to not include the thing it finds in the search result. So (?=~8) means to "look ahead" for a bullet character, but don't include the bullet character in the search results.
Putting it all together, we have (?<=\t)[^~8\t]+(?=~8) which means to:
Look for one or more characters that are not bullets or tabs, that are preceded by a tab character and followed by a bullet, (but don't include the tab or bullet in the search results).
The (?<=\t)[^~8\t]+(?=~8) string can be used in InDesign in two different places:
1. The GREP tab of the Find/Change dialog box, to do a search based on the GREP expression, or
2. The GREP Style tab of the Paragraph Style Options dialog box, which allows you to have InDesign assign a character style automatically any time that the GREP expression is matched.