Copy link to clipboard
Copied
Hi, Dear Friends!
I think this question has been addressed before, but I don't recall the final verdict.
Is there a way to have a certain PAR style cause the first word of that paragraph to have a certain character style? Or as a workaround to cause ID to format the first word of all, or some, paragraphs with a certain character style.
Thank you, and have a good day!
Susan Flamingo
Copy link to clipboard
Copied
I needed this really fast for a job toady, so I "cheated" and asked ChatGPT and here is the answer it gave:
To use a grep style within the paragraph style and use the syntax: ^\w+ and apply the character style.
Actually worked.
I wonder if this community will someday be connected to an AI LLM system for instant answers to posted questions. It could be done in a day of programming, I think. But thanks to all anyway!
Thank you, and have a good day!
Susan Flamingo
Copy link to clipboard
Copied
Yeh that's the way to do it.
You can also use Nested Styles and apply it the first word.
Using ChatGPT is not cheating, it's working smart.
I'd hate the forums to be automated messaging, it's a user to user forum.
Copy link to clipboard
Copied
And in fact I think that nested styles is the better option. Paragraph GREP styles that are heavily used in a document can cause slowdown...
Copy link to clipboard
Copied
Right! GREP is a horrible idea for this and a nested style would take about a minute or two to create.
Copy link to clipboard
Copied
My first instinct when people request GREP styles is to use Nested Styles.
I don't know why everyone looks for GREP styles, I guess it's cool. But nested styles requires zero GREP knowledge and tends to work better.
Many a time I've suggested using Nested Styles, seems to be an overlooked and underused feature - not as 'cool' as GREP or something.
Copy link to clipboard
Copied
And ChatGPT gave you the wrong answer 😉
It's a tool - powerful tool - but it isn't smart. It's just a very advanced statistical model - it just guesses the right answer...
Copy link to clipboard
Copied
No. You are wrong.
It gave the exact answer that worked perfectly. (It could be scrapped from this forum, but it was correct!)
Copy link to clipboard
Copied
Hi @SuzzyFlamingo , You may or may not notice the performance hit using a GREP Syle, but when you can use a Nested Style instead it is always preferable—ChatGPT must have forgotten about the performance issues.
Copy link to clipboard
Copied
@SuzzyFlamingo You're absolutely right ChatGPT did give a correct answer. Using a GREP style with ^\w+ to apply a character style to the first word of a paragraph is totally valid and works exactly as described. Just because there's another way to do it (like nested styles) doesn't make the GREP method wrong.
InDesign often gives us multiple tools to do the same thing, and which one you use can depend on your specific needs, deadlines, familiarity, document complexity and all that.
ChatGPT got it right for your use case, and it's good to see you got the result you needed fast. The solution worked. And that's the whole idea, isn't it?
For future reference and based on user experience, which ChatGPT doesn't have, Nested Styles are usually better for this kind of task, especially performance-wise. But there's nothing wrong with doing it either way. Your solution worked, and that’s what matters.
Copy link to clipboard
Copied
No. You are wrong.
It gave the exact answer that worked perfectly. (It could be scrapped from this forum, but it was correct!)
By @SuzzyFlamingo
Yes, technically - as one of possible solutions - it's correct - but it should've suggested Nested Styles instead.
Copy link to clipboard
Copied
I've got a question for those who believe that nested styles do better and perform better than GREP styles:
what engine do you think is under the hood of nested styles?
GREP or magic?
Copy link to clipboard
Copied
😄 Nested are much simpler in implementation and were first - so most likely two different "technologies".
You don't have dynamic comparison - just character/glyph or word.
Copy link to clipboard
Copied
That's a great question
Nested Styles are built into InDesign’s text formatting engine as a simpler, rule-based system. They’re not powered by the full GREP engine. Instead, they use positional and word-based logic, things like "up to 1 word", "through 1 sentence", "up to a specific character", not regex parsing.
GREP Styles, on the other hand, use InDesign’s implementation of the Perl-Compatible Regular Expressions (PCRE) engine. It's heavier, more flexible, but also more processing-intensive, especially in documents with lots of live GREP rules.
So while both affect how styles are applied dynamically at render time, Nested Styles are a lightweight, custom-built rule set, and GREP Styles are regex-driven, which can mean a performance hit in complex documents.
Copy link to clipboard
Copied
Nested styles use the old "Seattle" magic...
Copy link to clipboard
Copied
Nested Styles predate GREP by several versions, so whatever algorithm Adobe uses to implement Nested Styles, it’s much simpler than GREP.
Copy link to clipboard
Copied
Back in Version 3 aka CS, Adobe published a copy of the generated documentation, a newer version of that still comes with the plug-in SDK downloads.
InDesign has indeed dedicated functions (in the compose scanner) to deal with words, considering the language and custom criteria what characters belong into a word. My first thought, but wrong here.
You're right that expressions are used, just not regular expressions.
The mechanism for nested styles and drop caps internally is called RunInStyle.
When we look at the attribute storing the "through 1 Word" nested style, the trigger expression is "(^w)1"
The expression for "through 1 Sentence" is "(^S)" and "up to 2 End Nested Style" is "[^p]2"
So, "through" is round brackets, "up to" is square brackets, followed by the count without curly brackets.
Very different from regular expressions.
This is an expression engine at work, but a much simpler one - therefor faster.
As @TᴀW calls it - Seattle magic.
Copy link to clipboard
Copied
You're quibbling, whatever the implementation method, it's always regular expressions under the hood.
Copy link to clipboard
Copied
Interesting take on it - can you share where you found this information?
I am pretty sure that it's not using the same engine as GREP - but would love to know more about it and if you have any information or resources to share it'd be great to read up on.
I thought I explained it wasn't quite well, but you have piqued my interest to learn more.
Copy link to clipboard
Copied
Please, be lenient since English is not my native language.
I didn't mean to imply that they were the same engine, I just meant that no matter how you implement them, it's always regular expressions that are under the hood.
Copy link to clipboard
Copied
Please, be lenient since English is not my native language.
I didn't mean to imply that they were the same engine, I just meant that no matter how you implement them, it's always regular expressions that are under the hood.
By @JR Boulay
Why do you think that?
If that would be true - then GREP Styles would be from the start - and probably instead of Nested.
Copy link to clipboard
Copied
Of course, no problem, just curious to your claims and wanted to know more.
I think they might use expressions but different engines as @Dirk Becker points out expertly.
Nested styles are a simpler implementation and works quicker.
GREP is a different engine and more complex.
But both use expressions but different engines.
Copy link to clipboard
Copied
That's exactly what I meant. 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now