Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Using GREP to Format

New Here ,
Nov 22, 2021 Nov 22, 2021

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

TOPICS
How to

Views

313

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 22, 2021 Nov 22, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 22, 2021 Nov 22, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 23, 2021 Nov 23, 2021

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 23, 2021 Nov 23, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 24, 2021 Nov 24, 2021

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 24, 2021 Nov 24, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2021 Dec 01, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 25, 2021 Nov 25, 2021

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

Hi @Creamer Training 

Have attached an example InDesign file and data for data merge that I have been using.

Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2021 Dec 01, 2021

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. 

image.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2021 Dec 01, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2021 Dec 01, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 01, 2021 Dec 01, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 02, 2021 Dec 02, 2021

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:

 

Capture d’écran 2021-12-02 à 11.03.06.png

 

(^/)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

Thats exactly what I am looking for. Can you please share how you were able to make it work?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2021 Dec 01, 2021

Copy link to clipboard

Copied

You could also separate the paragraphs with line breaks (shift-returns), effectively turning it into one large paragraph. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines