Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hello Peter,
i read this that the poster wants his text "automatically" formated.
How about…
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks, pkahrel. Although not automatic, the Find/Change feature actually works perfectly and will be very helpful.
Thanks very much.
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
Nice one, Vinny. But you have to be typing for that, don't you?
Copy link to clipboard
Copied
Hmmm not sure I understand what you mean pkahrel...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.