Copy link to clipboard
Copied
I have no idea if this is possible or not, have come across and research GREP style for the first time today, and can't seem to find an answer that helps
Are you able to use GREP to format all text in text box?
As an example I have a text box with a large amount of black text, I would like to change the text colour of all text if a certain word, lets say 'Apple' is present anywhere in this text box
Is there a way to define this in the GREP style?
Thanks
Copy link to clipboard
Copied
Try the following in your Grep style
(?i).*Apple.*
And apply a new character style with the desired color.
-Manan
Copy link to clipboard
Copied
Or better you could even use the following
(?i).*\bApple\b.*
The previous one would apply the character style if apple is found anywhere in the text even within a work like pineapple. But this one will apply only when apple is present as a word. Also both the options are case insensitive. If you want case sensitive match then remove (?i)
-Manan
Copy link to clipboard
Copied
Thanks for the response @Manan Joshi
Your solution almost works, I have applied as suggested however it only makes that one paragraph blank, rather then all paragraphs/text in the text box. Any thoughts?
Copy link to clipboard
Copied
GREP Sty;es can only affect paragraphs one at a time. The content of one paragraph can’t afect another paragraph.
Copy link to clipboard
Copied
Are you using Paragraph styles or apply the GREP style directly to the text?
If using Paragraph styles, have you applied the style to all the desired text?
Copy link to clipboard
Copied
Hi @Dave Creamer of IDEAS, I tried both
What I was looking for is a solution that would change the format of ALL text in a text box,
When applying it as a paragraph style where
Apply Stlye: Character style 1 - which changes text colour to white
To Text: (?(?i).*move.*
and using a variable data merge, where some records include the word move. This then removes the paragraph where the variable field is but not the remaining text in the text book
And its not practical to apply the variable field to every paragraph
When applying it as a GREP style directly there is not ability to apply the criteria as above, so all text turns to white but wthout the key logic
Any suggestions on another work around would be greatly appreciated
Copy link to clipboard
Copied
Hi @davidp96673165,
Can you try the find/change feature, if yes then you can use the following grep expression
Find What:
(?i)((\n|\r|.)*\bApple\b(\n|\r|.)*)
Change to:
$1
And use the change format option to apply the character style that changes the color. See the screengrab of it working.
-Manan
Copy link to clipboard
Copied
That does work mate
Not the dynamic solution I am trying to get to but as a permanent change it works.
Copy link to clipboard
Copied
I suspect the paragraph style is not applied correctly. If you can upload a document to look at, it would be easier to see what is happening.
Copy link to clipboard
Copied
Have attached an example InDesign file and data for data merge that I have been using.
Thanks
Copy link to clipboard
Copied
You only had the basic paragraph style used. I don't know if it was just for this example or not, but you should create your own custom styles and avoid using that one.
Anyway, the problem was you had overrides to your style. Notice the little plus sign [+] next to the Basic Paragraph style when put your cursor in the text. Remove the overrides using the button at the bottom and it worked. (Select the text first.)
Note that the character style is set to apply the color "none". This will hide the text but still leave a big gap in the text block.
Copy link to clipboard
Copied
Thanks for the adivce, but yes only had the basic style for this example
Yes I had an override on the style so I could see the field in question to ensure it was working correctly.
What I am searching for is a solution that will hide ALL 5 paragraphs not just the one that contains the field in question.
Copy link to clipboard
Copied
ALL the paragraphs would have to contain the word that triggers the GREP code.
You might want to look at a database plugin that has if/else logic. There are multiple plugins, but I've InData.
Copy link to clipboard
Copied
If your target is the word "FRIdNGE" (or "fridnge" or "FRIDNGE"), use a F/R [a Grep style won't work here!]:
Find: (?si).*\bFRIdNGE\b.*
(^/) The Jedi
Copy link to clipboard
Copied
Addendum:
If the target-word could be included too (you talked about "data merging") at the end of the text, directly in the source-csv (I've keeped the sample-word "TAX" in blue but the 2nd Grep Style will make it invisible), so, sure, totally automatic with 2 grep styles, even if "TAX" is not in some paras! 😉
As:
(^/)
Copy link to clipboard
Copied
Thats exactly what I am looking for. Can you please share how you were able to make it work?
Copy link to clipboard
Copied
Just a friendly bump. Anyone able to help as to how this is achieved, spent a lot of time replicating but have not been able to achieve the same above results. What help massively if you could assist. Thanks
Copy link to clipboard
Copied
You could also separate the paragraphs with line breaks (shift-returns), effectively turning it into one large paragraph.
Copy link to clipboard
Copied
Thanks for the suggested, I spent to looking at soft returns yesterday, but I couldn't get it to work. As soon as i seperated a pararaph (shift+enter) the text would change back