Maybe this could work:
We're trying to get it working as a GREP style, rather than a find change operation.
It seems to be the positive lookbehind that is stopping us. It doesn't seem to like anything too complex attached to it.
I don't see a reason to use a GREP style at all. And ordinary nested style ought to work...
None through 2 words, <no fill style> up to the trigger of your choice should do it.
GREP styles only style things; they don't change content.
A nested style won't do, because it must only apply to an occasional paragraph of a certain style; not each one of them.
The OP has already said the intent is to "hide" the text by using a fill of None applied via style. Nested style would do that just as well as the GREP style, and doesn't have a problem finding two words at the start of a paragraph.
Yes, but would that leave a big white space in the text?
Absolutely. My presumption here is that they don't care because there is nothing following.
As you've already pointed out there is no way to actually remove text using a style, but I suppose the size of the "hidden" text could also be reduced to something very small, and a large negative tracking applied, all in the same style that makes the fill none, which might be enough to "remove" a space between the first name and punctuation at the end.
That might be so, yes.
1 person found this helpful
Nested styles would work if every paragraph starts with 'Dear'. If that's not the case, then you would have to use GREP styles, and using two styles, Steve can accomplish what he wants. The problem he had was that whatever a lookbehind matches must be the same size, which is why lookbehinds don't work with the operators + and *. The following approach works:
First Grep style:
char. style "blank" (0.1 points, horizontal scale 1%, fill colour none)
Second Grep style:
char style 'normal'
So what you do is (1) apply "blank" to first and last name, then (2) apply "normal" to first name.
Peter Kahrel wrote:
Nested styles would work if every paragraph starts with 'Dear'.
I don't mean to contradict here, especially since that's a mighty clever GREP approach, but nested styles don't care a whit about whether the paragraphs starts with "Dear" or "you jerk." The nested style simply counts words, characters, or whatever other trigger you give it. In fact, nested styles are completely unable to identify specific text strings (you cannot set them to apply a style up to the word "cat," for example, as they will stop at the first instace of c, a, or t encountered, sort of like looking for a class with GREP). Seems to me you only need the GREP if there are cases where the paragraph DOESN'T start with Dear and you want to leave those alone.
> Seems to me you only need the GREP if there are cases
> where the paragraph DOESN'T start with Dear and you want to leave those alone.
Well, that's what I meant with "Nested styles would work if every paragraph starts with 'Dear'."
OK, I guess I just didn't catch your meaning the first time through. Can I use sleep deprivation as an excuse?
Of course this is just my opinion, but I think if there is some styling to be done, either nested or GREP, one ought to be limiting the paragraph style to only those paragraphs that would be salutations, even if that means using a Based On style realtionship to isolate it. Given the description of the problem where the paragraphs seem to start with "Dear," I'd be willing to bet that there are not cases of paragraphs in that position in the merge that don't start that way.
And I really do like your solution.
And since we're talking theoreticals here, the nested style would work unmodified if the paragraphs had several salutations, such as Dear, Honorable, and Esteemed, but I think I'm going over the top at this point.
You're probably right that every paragraph starts with Dear, and that therefore the nested option is better (because quicker). That nested styles can deal with several salutations holds for Grep styles too, though you'd have to specify each salutation -- though that might be an advantage.
Anyway, nested styles it is!
Peter - I think we were trying too hard to use GREP styles and forgetting about nested styles - which work perfectly.
We had been using GREP styles in other parts of the job to automatically style words and apply colour, so I guess we had just thought we could accomplish one more thing.
A case of not seeing the wood for the trees I guess, but still an interesting exercise working with GREP.
I'm a big fan of GREP styles and have used them to accomplish some really useful stuff, but I'm definitely still learning so I appreciate the help.
No question, GREP styles are extremely powerful, and they can do a lot of pretty cool things you can't do any other way, so any time you spend exploring GREP and improving your skills is probably far from wasted. That said, it's good to remember that GREP styles can be a drag on performance and if a nested style will do what you want, it's probably more efficient.