Skip to main content
simon cederholm
Inspiring
May 3, 2023
Answered

GREP in a Table row

  • May 3, 2023
  • 3 replies
  • 1616 views

Im working on a calendar in InDesign. The calendar is a table with four cols. The first one is a single number for the date of the month, the secont is the first letter of the coresponding day. Im trying to turn the text in every row that contains a "s" for sunday, red by applying a GREP paragraph format but i can't seem to get it to work. I can get the "s" red but need help with the rest. Any pointers?

 

 

This topic has been closed for replies.
Correct answer Thunder-Lightning

[Saw Scott's response after I posted this] As suggested by @Scott Falkner is to have the date and day both in a cell, separated by a tap, then you can use GREP style ^\d+\t[sS] to make both red.

You can use the SmartCellMerge.js from indiscripts.com to merge across the columns of each row. Find a paragraph return and replace with a tab in those cells.

3 replies

Thunder-LightningCorrect answer
Inspiring
May 9, 2023

[Saw Scott's response after I posted this] As suggested by @Scott Falkner is to have the date and day both in a cell, separated by a tap, then you can use GREP style ^\d+\t[sS] to make both red.

You can use the SmartCellMerge.js from indiscripts.com to merge across the columns of each row. Find a paragraph return and replace with a tab in those cells.

Inspiring
May 8, 2023

Hi @simon cederholm,

I can't see how GREP style can make the number before the 'S' red, as they are separate paragraphs in different cells.

Can you do a GREP Find/Change and apply a character style to the number and 'S' that makes them red before converting it to tables?

Another way is to use a script to make the contents of the cell red if the next cell contains a letter 'S'.

Community Expert
May 8, 2023

Hi @Thunder-Lightning ,

download my sample InDesign document where the same paragraph style is used in both columns:

https://community.adobe.com/t5/indesign-discussions/grep-in-a-table-row/m-p/13768293#M525563

Explanation here:

https://community.adobe.com/t5/indesign-discussions/grep-in-a-table-row/m-p/13768152#M525558

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Inspiring
May 8, 2023

Thanks, @Laubender , for the InDesign file.

As far as I understood the question, the number is not always 1 on Sunday in a calendar though so how would they use the GREP style to colour the number?

Community Expert
May 3, 2023

Hi @simon cederholm ,

can you show a screenshot of the GREP Style you are currently using with the paragraph style that is applied to the table's text? What is "the rest"? What are the key characters you want to color? And please show at least some rows of your table with hidden characters showing; also frame edges so that we can see clearly a table cell's boundaries.

 

Note: You need one character style for each color you want to apply.

And also one GREP Style per used character style and color.

 

GREP Style pattern for the first character "s" in a given table cell:

^s

 

Better*, if you only like to do this with sunday, to do a positive look ahead with the rest of the word:

^s(?=unday)

 

For monday it will go like that:

^m(?=onday)

 

[*] Of course to make this work the whole word must be present as the first word in the table cell.

 

Also note, that a GREP Style cannot work beyond a given paragraph. It cannot pick up the contents of an adjacent text cell and react upon it.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Community Expert
May 3, 2023

I said:
"[*] Of course to make this work the whole word must be present as the first word in the table cell."

 

If the whole word cannot be present visually you still can use the whole word in the text cell, but you have to obscure all characters but the first one in the word by applying a character style where the fill color is set to [None], the text is scaled down with a tiny point size like 0.1 Pt and also perhaps scaled to 1% in width and height.

 

Regards,
Uwe Laubender
( Adobe Community Expert )