-
1. Re: Apply grep style only once
Laubender Jul 31, 2012 10:25 AM (in response to RobertKyle)@Robert – try this one:
^.+?:+?
Uwe
-
2. Re: Apply grep style only once
RobertKyle Jul 31, 2012 11:05 AM (in response to Laubender)Perfect! Thank you. But what does it say? I get "beginning of paragraph, any number of characters" but after that it's murky to me
-
3. Re: Apply grep style only once
Laubender Jul 31, 2012 11:25 AM (in response to RobertKyle)@Robert – I did a little trial and error and we can reduce the expression to:
^.+?:
It's the "not greedy" version of:
^.+
followed by the colon.
My first attempt added a not needed part I did not delete after experimenting.
Uwe
-
4. Re: Apply grep style only once
RobertKyle Jul 31, 2012 11:39 AM (in response to Laubender)Thanks again. So now I'm wondering how to limit the grep to the first line? I see the modifiers for single line on and multi line off, but I'm obvously not putting them in the right position
-
5. Re: Apply grep style only once
[Jongware] Jul 31, 2012 1:19 PM (in response to RobertKyle)A-ha. Now that is not possible with GREP styles -- they are part of a paragraph style, and strictly limited to text inside each paragraph. No peeking out of it either way. Single-line and multi-line modifiers do not work, and neither does fiddling with \r anywhere inside a GREP style.
You have to create another paragraph style containing this GREP only, and apply it to your first paragraph.
-
6. Re: Apply grep style only once
Laubender Aug 1, 2012 12:33 AM (in response to [Jongware])@Jongware – I think Robert wants to limit the GREP style to the first line of a paragraph.
But unfortunately GREP in InDesign does not know about line endings.
In scripting we could do something like what he wants, but comes with some obstacles, because the GREP will apply a character style, that will probably change the line ending. A very dynamic situation…
Example 1
Basic situation:
This is my text here comes the colon: and
here another one: that Robert don't like
to take into account using the GREP style.
Formatted after the GREP style is applied:
This is my text here comes the colon: and
here another one: that Robert don't like
to take into account using the GREP style.
As I understand it, in case that the first colon will leave line one, only the first line should be formatted like this:
(Case 1)
This is my text here comes the first
colon: and here another one: that
Robert don't like to take into account
using the GREP style.
Or should it be, that the style should only be applied, if it's in the first line?
(Case 2):This is my text here comes the first
colon: and here another one: that
Robert don't like to take into account
using the GREP style.
But what, if the colon in the basic case is at the end of line 1 and will be shifted to line 2 after formatting?
What should happen then?
That is simply not possible to format automatically (dynamically) using GREP styles in InDesign.
Uwe
-
7. Re: Apply grep style only once
P Spier Aug 1, 2012 3:40 AM (in response to Laubender)Uwe, I don't see that at all in the original post. He seemed quite clear to me that he wanted to apply the style up the first colon, no matter where, and not beyond, and that the style should only be applied IF there is a colon, ruling out a regular nested style. The only reference I see to anything like the first line is the beginning of paragraph mark.
-
8. Re: Apply grep style only once
Laubender Aug 1, 2012 4:29 AM (in response to P Spier)@Peter – I assumed this because of:
So now I'm wondering how to limit the grep to the first line
in #4.
I could be totally wrong…
Uwe
-
9. Re: Apply grep style only once
P Spier Aug 1, 2012 4:31 AM (in response to Laubender)Ah yes, missed that. It is ambiguous, isn't it?
-
10. Re: Apply grep style only once
Laubender Aug 1, 2012 4:47 AM (in response to P Spier)Yes.
If a "Nested Line Style" could overwrite a "GREP Style", we could manage that, but "unfortunately" that isn't…
Not working example:
GREP Style:
Apply Style: "BoldFont_CharacterStyle"
To Text: ^.+?:
Nested Line Styles:
[None] for 1 lines
"RegularFont_CharacterStyle" for 999 lines
Uwe
-
11. Re: Apply grep style only once
P Spier Aug 1, 2012 4:59 AM (in response to Laubender)suppose you approach it the other way. Apply the line style to the first line and then apply a GREP style to UNdo it after the first colon with a lookbehind? Not quite sure how to make that work so the line style is removed if there is no colon... Perhaps a second GREP style that looks for the string at the beginning and checks for a colon, but I'm not sure how to prevent that from being applied if the colon is found.




