Hey all, I'm trying to eliminate many lines of text in InDesign. The only lines of text I want to keep are those that contain certain keywords.
The block of text changes every time we use it, and it may or may not contain one or more instances of any of the keywords. It also will contain occasional special characters and definitely will have digits and spaces.
Here's an example of a text block we might receive:
Team 65, Team Teamy 53
St. Teamy 55, Team 52
TeamA at Team Beee, 7:30 p.m.
Team-Teamy at St. Teamer's, noon
From that example, we might want to kill every line that does NOT contain "St. Teamy" or "Team Beee".
Is this possible? I'm no pro GREP-er, but I haven't found a solution yet. I want to run this GREP query through InDesign, and I'm OK with multiple queries if necessary. Thank you for your time!
Are these all one paragraph, or is each line a separate paragraph? Unless each line is it's own paragraph I don't think you have a prayer of getting a GREP solution. though it's probably scriptable.
You could do it as follows:
1. Add some format to all lines that contain your keyword(s), e.g. underline.
2. Delete everything that's not underlined.
3. Remove the undrline codes.
But how do you identify single lines if they are part of a larger paragraph?
If they are part of a multi-line paragraph you're not going to find then with a single GREP expression, you'd need a script for that. That goes for both mine and Michel's (much better) solution. In Michel's expression, change the final \r? to [\r\n]? to get it to work in single paragraphs with forced line breaks.
… Supposing each line is a single para:
(^/) The Jedi
Many thanks for the quick responses! And, to answer: every line is indeed its own paragraph. I'll report back after I do some testing. Thanks again...
Yep, seems to work like a charm. Thanks again to the community here, much appreciated!