-
1. Re: Using GREP to style text - help!
Joel Cherney Sep 20, 2012 9:40 AM (in response to leepaulvickers) -
2. Re: Using GREP to style text - help!
winterm Sep 20, 2012 2:34 PM (in response to leepaulvickers)Oh, but with grep... it's more fun! And what if you don't want to touch (format) those pipe chars?
I think you should look closer to "look behind" and "look ahead" expressions.
-
3. Re: Using GREP to style text - help!
Joel Cherney Sep 20, 2012 2:37 PM (in response to winterm)Ach. Yeah, the nested style should have been "up to" not "through." Then the character style would not be applied to the pipe characters. I tried to gin up a GREP query, but couldn't pull it off; it's beyond me. Besides, since more than one character style needs to be applied, it ought to take more than a single query to apply both bold and italic styles. That's unnecessary duplication of effort, if you ask me.
Besides... are you going to take a stab at it?
-
4. Re: Using GREP to style text - help!
Marijan Tompa [tomaxxi] Sep 20, 2012 2:53 PM (in response to leepaulvickers)I would also use nested styles, like Joel suggested, but this will escape pipe character:
Style 1 up to 1 |
[None] through 1 Character
Style 2 up to 1 |
[None] through 1 Character
Style 3 up to 1 \r
Hope that helps.
--
Marijan (tomaxxi)
-
5. Re: Using GREP to style text - help!
winterm Sep 20, 2012 2:54 PM (in response to Joel Cherney)huh, I have a project every month, where specific line of digits and some chars is used hundred and hundred times...with very different formatting - up to 8 (yes, eight!) different char styles. All is build on grep, all I need to do - just click para style. I'd be dead to do it manually.
So its surely doable, and I guess OP wants just the direction. I think it's "look ahead" and "look behind".
-
6. Re: Using GREP to style text - help!
Peter Spier Sep 20, 2012 3:37 PM (in response to winterm)As Joel said, to apply three character styles you'd need three GREP styles, though they could all be in the same paragraph style. Nested styles, however, if they will work with the constuction of the paragraph, are FAR more efficient for processing.
-
7. Re: Using GREP to style text - help!
Joel Cherney Sep 20, 2012 3:37 PM (in response to winterm)All is build on grep, all I need to do - just click para style.
Aha! It's not a GREP query, but a collection of GREP styles. And you didn't write 'em! Busted!
Yeah, assuming that there are only two pipes in any one paragraph, and that there are never paragraphs with pipes that should not have these styles applied, then it would be possible to write GREP queries that looked for these patterns. Okay, here's the query that finds the middle one between the pipes:
(?<=\|).+(?=\|)
That's a positive lookbehind for a pipe, then "just find anything, anything at all," then a positive lookahead for a pipe. If you made a GREP style in your paragraph style with this query, and used it to apply an italic character style, then you... er, I, I mean I... would have spent about four times as much effort on a GREP style than I would have on half of a nested style.
Whatever floats yer boat, wintermute.
-
8. Re: Using GREP to style text - help!
winterm Sep 20, 2012 3:56 PM (in response to Joel Cherney)Joel Cherney wrote:
All is build on grep, all I need to do - just click para style.
Aha! It's not a GREP query, but a collection of GREP styles. And you didn't write 'em! Busted!
no, I wrote them... but yes, that is a collection of styles. Somewhat like this:
really not a big piece of art, but it works, and can be used as a starting point.its up to everyone to decide, what to use. What and when. Frankly, I almost forgot nested styles even exist...
-
9. Re: Using GREP to style text - help!
Joel Cherney Sep 20, 2012 4:01 PM (in response to winterm)That's clever, using a positive lookahead with the beginning-of-paragraph marker. I (obviously) didn't think of that. Okay, I retract my callout.
-
10. Re: Using GREP to style text - help!
leepaulvickers Sep 21, 2012 1:51 AM (in response to winterm)Wow, you guys have been busy!
Thanks winterm, this worked perfectly. However, the language is a bit beyond me at the moment so I have some learning to do! Really clever stuff this GREP malarky, will save me lots of time in the future.
-
11. Re: Using GREP to style text - help!
Peter Spier Sep 21, 2012 6:53 AM (in response to leepaulvickers)Let me repeat what I said earlier about GREP Styles and processing efficiency. GREP Styles check the text at every keystroke to see if there pattern is matched. A number of experienced regulars here have reported significant slowdowns in performance when GREP Styles are used heavily in their files. I firmly believe using a nested style instead, whenever appropriate, is a better workflow.
-
12. Re: Using GREP to style text - help!
winterm Sep 22, 2012 3:12 AM (in response to Peter Spier)Huh, Peter,
with all my respect - grep styles are much more powerful and flexible than nested styles, you can do A LOT more things with it. Maybe its overkill to use grep in this particular case, however, let's treat it as a part of "learning grep" process for OP. Excuse me for reminding, he asked for "grep solution" (not nested styles), and here it is.
Now your answer seems to me like:
"Q.: How can I do it in InDesign?
A.: You shouldn't do it in InDesign, you better do it in Word, because in this particular case it's more efficient"
Huh?
I see efficiency as a secondary thing this time.
@leepaulvickers:
among other good sources, I believe you should give a try to this nice thingy, called What the GREP:
http://www.jongware.com/idgrephelp.html
ah, talking about scripts and greps... you better read twice everything, signed with this name... if you can't dig in it today, bookmark it and come back tomorrow.
Jongware is The Master.
-
13. Re: Using GREP to style text - help!
Peter Spier Sep 22, 2012 6:14 AM (in response to winterm)@ Winterm,
GREP styles are absolutely more powerful and flexible than nested styles, and they certainly are an important part of the toolkit, but you don't use a sledgehammer to drive tacks.
If my memory serves, both Dave Sanders and Jongware are among the users who have reported ID lagging when more than a few GREP styles are in use, and that the same files suddenly come to life when the GREP styles are removed. This may not be a problem for everyone, obviously, but if you use a lot of GREP styles and base other paragraph styles on paragraph styles that use GREP styles, you need to be careful or you could find yourself waiting for ID to respond while you type.
It's kind of like taking the the 200 lbs of wintertime sand out of your car in the summer to boost your fuel economy if you live in an area with lots of snow.
As for your analysis that I'm saying don't do it in ID because it's inefficient, and that we should supply the GREP solution because that's waaht was requested, well, nested styles are a part of ID, too, and one that the OP also seems to need to learn. I'd compare this more to a case of teaching someone to use styles instead of telling them how to use the eyedropper to pick up local formatting and apply it hundreds of times through a document.
-
14. Re: Using GREP to style text - help!
Joel Cherney Sep 22, 2012 8:56 AM (in response to Peter Spier)Well, let's see. The original poster expressly wanted to learn how to write a GREP expression. The OP learned how to write that expression, and also learned one way of employing such an expression - in a GREP style.
-
15. Re: Using GREP to style text - help!
Peter Spier Sep 22, 2012 9:01 AM (in response to Joel Cherney)You left out that he also learned that for this particular patter a nested style is better (at least inthe opinion of several of us who responded).
-
16. Re: Using GREP to style text - help!
Joel Cherney Sep 22, 2012 9:05 AM (in response to Joel Cherney)But a GREP style, while incredibly useful in many circumstances, is not the most efficent tool for the job. I too have experienced some significant lag when my document is overladen with GREP styles. I've not seen that with nested styles. The fact that GREP is more fun is undeniable but when you say "I forgot that nested styles even exist" it means that you're over-using your Swiss Army knife and need to take a good look at your Torx wrenches.
-
17. Re: Using GREP to style text - help!
winterm Sep 22, 2012 11:32 AM (in response to Peter Spier)Peter Spier wrote:
hm, sometimes I use... and see no devil in it if sledgehammer remains under control
[...] ID lagging when more than a few GREP styles are in use [...] you could find yourself waiting for ID to respond while you type.
In one of my every-month project I use A LOT of grep styles with no problems. Even more, I'm sure they are miles away from perfect - I wrote them myself about year or two ago...
And... sorry, I'm a designer, not a typist. There is some word processing proggies for typing
nested styles are a part of ID, too, and one that the OP also seems to need to learn.
absolutely agreed! So far so good for OP - he learned both ways, that's the right method of learning.
I'd compare this more to a case of teaching someone to use styles instead of telling them how to use the eyedropper to pick up local formatting and apply it hundreds of times through a document.
sorry, couldn't agree again. In my above mentioned project I use eyedropper so heavily, I even created kb shortcut for it while being in text mode - just for copying text attributes. Styles not always serves you right way, so do nested or grep styles... Everything depends on specific project workflow and, well, your own "style" and preferences.
Simply: you must know as much as possible ways to achieve your goal and... choose wisely every moment.
@Joel:
thank you for understanding my formal ground
-
18. Re: Using GREP to style text - help!
winterm Sep 22, 2012 11:24 AM (in response to Joel Cherney)Joel Cherney wrote:
But a GREP style, while incredibly useful in many circumstances, is not the most efficent tool for the job
"Most efficient tool" is your brain. Always.
yes, maybe i'm overusing grep, but please don't kick me, it's still a new interesting toy for me... I still have a lot to learn about it, how could I without using it?
[...] when you say "I forgot that nested styles even exist" it means that you're over-using your Swiss Army knife and need to take a good look at your Torx wrenches.
Yes, and I'm thankful to You for reminding. I'll definitely take another look to it. After few years of oblivion...