No, I don't believe you can use nested styles to do this. With nested styles, each unique glyph you add to the nested style can trigger on particular character style. And one particular character style can only set on particular swatch color.
I imagine it could be scripted, however (but I'm not a scripter).
Thanks for the reply. I found an alternative:
First setting the paragraph to have the first letter of the word a different color. Then adding a second nested style to make the rest of the word another color. I would then repeat these steps over and over again for each word. This means that each word on the line would have 2 nested styles. Then I would just press enter to start a new line which runs the nested style from the top again.
You could do it with a GREP style automatically.
Right. I thought as well of that but I was convinced a nested style would work. (Quite a surprise it doesn't.)
Depending on how narrow or wide the definition of a "word" is, this may already do it:
One possible drawback is that the default "word" characters include digits as well. If those should not be included, you'd have somthing like
where the \u is for uppercase and the \l ("ell", not "Eye") is for lowercase.
Both these GREP expressions depend on the correct interpretation of "\b" for a "word break" boundary. If you find it highlight characters where it should not, let us know and we'll look for an alternative.