Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

GREP styling on multiple lines

Explorer ,
Jan 25, 2017 Jan 25, 2017

Is it possible to use GREP styling to automatically format something like this below?

The typical pattern is a Bold paragraph style on the second line. However, I want a different character style automatically applied when the previous line has the word REGULAR. Likewise, if the previous line has the word PREFERRED, then I want a second character style to automatically be applied.

Thanks for any help or suggestions.

2.4K
Translate
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

correct answers 1 Correct answer

Community Expert , Jan 25, 2017 Jan 25, 2017

Find what: REGULAR\r\K.+

Change to: <Leave blank>

In the 'Change format' panel, set the character style you want to apply to the dollar amount.

Find what: PREFERRED\r\K.+

Change to: <Leave blank>

In the 'Change format' panel, set the character style you want to apply to the dollar amount.

\r stands for the paragraph break, \K means 'match any preceding text but don't include it in the replacement'.

P.

Translate
Community Expert ,
Jan 25, 2017 Jan 25, 2017

How is this organised? Are e.g. 'REGULAR' and '$00.00' in a cell the same paragraph, separated perhaps by a forced or a normal paragraph break? Can you show a screenshot with special-character display on?

Peter

Translate
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
Explorer ,
Jan 25, 2017 Jan 25, 2017

This is constructed with multiple embedded text frames (set to auto expand when the text or currency changes because of foreign translation), each frame separated by an embedded line.

Translate
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
Community Expert ,
Jan 25, 2017 Jan 25, 2017

Find what: REGULAR\r\K.+

Change to: <Leave blank>

In the 'Change format' panel, set the character style you want to apply to the dollar amount.

Find what: PREFERRED\r\K.+

Change to: <Leave blank>

In the 'Change format' panel, set the character style you want to apply to the dollar amount.

\r stands for the paragraph break, \K means 'match any preceding text but don't include it in the replacement'.

P.

Translate
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
Advocate ,
Jan 26, 2017 Jan 26, 2017

Hello Peter,

i read this that the poster wants his text "automatically" formated.

How about…

Bildschirmfoto 2017-01-26 um 13.27.08.png

Translate
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
Advocate ,
Jan 26, 2017 Jan 26, 2017

Edit: Arrrg, just saw "multiple lines", which is notghing for GREP working within a paragraph.

But maybe you could cheat in that case and use a single paragraph, and format the second line to look like a new paragraph (e.g. space_after to baseline_shift)

Translate
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
Community Expert ,
Jan 26, 2017 Jan 26, 2017

Well, if he wants to use a grep style then, as you say, he'll have to replace the paragraph breaks with forced paragraph breaks.

Translate
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
Explorer ,
Jan 26, 2017 Jan 26, 2017
LATEST

Thanks, pkahrel. Although not automatic, the Find/Change feature actually works perfectly and will be very helpful.

Thanks very much.

Translate
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
Guide ,
Jan 26, 2017 Jan 26, 2017

Hi

Here's another workaround:

You could use object styles and apply them to text frames.

Combining the paragraph styles option AND the Next style option, it's quite handy in your situation:

pattern.jpg

Translate
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
Community Expert ,
Jan 26, 2017 Jan 26, 2017

Nice one, Vinny. But you have to be typing for that, don't you?

Translate
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
Guide ,
Jan 26, 2017 Jan 26, 2017

Hmmm not sure I understand what you mean pkahrel...

Translate
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
Advocate ,
Jan 26, 2017 Jan 26, 2017

Vinny: If you apply that object-style, it works like a charm.

But if you change text in that text-box, the object-style gets a + and doesnt auto-reformat – you have to use "delete differences" to make it look right.

Translate
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
Guide ,
Jan 26, 2017 Jan 26, 2017

DBLjan: Yes, that's right, if you select both paragraphs. (not if you change only price i.e.)

Not knowing the op's workflow, I can't tell much more about what would be the most suitable solution: GREP, object styles, Search/Find, etc...

It's just a workaround... OP will choose ^^

Now, if I stick to the original request, I would vote nested GREP, after having replaced ¶ by ¬ as you both suggested.

Translate
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