In your case I would have maybe used GREP styles shown on the image below.
~h stands for
End Nested Style Here character which serves as a style divider (visible in special characters mode as a backslash). If you feel more comfortable with any other character feel free to replace all the
~h-s with anything you like from the drop-down menu.
The application order of the styles matters. Here are the expressions so that you could copy them:
For Style 2:
For Style 1:
In case you are interested in regular expressions used in GREP styles, here's how the above construction works:
First we apply Style 2 to everything from the first End Nested Style Here character (inclusive) to the end of the paragraph.
. means any character,
.* means any characters, any times which basically means all characters. So, the whole expression means ENSH character and everything after.
Then we apply Style 1 to everything between two ENSH characters (inclusive).
[^~h] means anything but a ENSH character. Thus,
[^~h]* means anything but an ENSH character, any times or, to put it simpler, everything until an ENSH character. So,
~h[^~h]* will mean everything starting from an ENSH character until the next ENSH character.
If we now leave the second expression as it is, the Style 1 will be applied to EVERY
“ENSH + text” pair. But if we include the following ENSH characher into this group too, the text AFTER the second ENSH will not meet the condition, just as needed. So we add
~h to the end of the expression and change it to
~h? to indicate that this ENSH is optional (as on line 3 on the example image).
You can learn more about the GREP syntax on any website that describes regular expressions like this one.