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?
Try the following in your Grep style
And apply a new character style with the desired color.
Or better you could even use the following
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)
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?
GREP Sty;es can only affect paragraphs one at a time. The content of one paragraph can’t afect another paragraph.
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?
Hi @Creamer Training, 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
That does work mate
Not the dynamic solution I am trying to get to but as a permanent change it works.
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.
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.
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.
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.
If your target is the word "FRIdNGE" (or "fridnge" or "FRIDNGE"), use a F/R [a Grep style won't work here!]:
(^/) The Jedi
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! 😉
Thats exactly what I am looking for. Can you please share how you were able to make it work?
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
You could also separate the paragraphs with line breaks (shift-returns), effectively turning it into one large paragraph.
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