Alright! Time for the final post in this series of GREP techniques! What I've done is created a graphic inside of InDesign using various tools. The end result is a vector-based element and I've highlighted it using the Direct Selection tool so you can see the points on the path that make up the shape.
Although I created this within InDesign, it could just as easily be a placed vector graphic from Illustrator or even an image from Photoshop. This method will work regardless of what type of graphic you are using.
Next you'll need to click on the graphic with your Selection Tool (black arrow) and choose Edit>Copy. Now switch to your Type Tool and click in an area of text where you'd like the graphic to appear and choose Edit>Paste. You've just created an in-line graphic which is a graphic that acts like a piece of text within InDesign. What we're doing here is setting up one instance of the graphic the way we'd like it to appear in all of our frames and then we'll automate it using GREP.
The main advantage of an in-line graphic is that it will behave like a character of text and therefore will flow with the text whenever an edit is made anywhere within the text that could affect the in-line graphic. (whew!).
At this point you could simply run the GREP search as you did in the previous post because it is actually pasting the contents of the clipboard in the change to: field. That being said, I can never leave well enough alone so I'm going to take it one step further. I'm going to precisely adjust the position of that graphic by making it an anchored object.
Click on the in-line graphic with the Selection tool and choose Object>Anchored Object>Options from the menu at the top of your screen. In the Anchored Object Options dialog box, set the Position to Custom, set the X relative to anchor marker and the Y relative to baseline, and turn the Preview checkbox on and click OK.
Now, if you haven't worked with Anchored Objects before, this dialog box can seem a bit daunting (leave comments if you'd like this to be a future blog topic) but we're going to simplify it. After you clicked OK, your graphic probably jumped away from where you originally pasted it which is fine. Using your Selection tool simply drag the graphic back to where it was and position it the way you would like it to appear with your text. Now go back to Object>Anchored Object>Options and check the "Prevent Manual Positioning" checkbox and click OK. This prevents anyone from being able to drag the graphic manually once you've positioned it.
We're almost done here so stay with me! We want all of the end-it graphics to appear in the same position relative to the end of the text so with that graphic still selected with your Selection tool, go to your Object Styles panel and Alt/Option+click on the Create new style button at the bottom of the Object Styles panel. Call the style end-it, Click the "Apply Style to selection" checkbox and click OK. An object style will apply the positioning that was applied to the end-it graphic to any other graphic that you apply it to. VERY IMPORTANT! Click on the end-it graphic and you're end-it Object Style should be highlighted in the Object Styles panel. CHOOSE EDIT>COPY. This will copy the graphic with the Object style applied to the clipboard.
Now, let's jump back into the Find/Change dialog box and click on the GREP tab. We're literally going to run the exact same GREP search that we did in part 2! Because the graphic with the Object Style has been copied to the clipboard, the Change to: portion of the GREP search should also apply the formatting to the replaced character. Run the GREP search on the Document (not just the story) and your end-it character should appear at the end of every story! Now, if you don't want the end-it character to appear after every single story in your document, the trick is to apply Paragraph styles to your text. In the example document that I've been using, I created several Paragraph Styles for the captions, body, and headings. What this allows me to do is indicate which stories of text to apply the end-it character to. Click on the More Options button within the Find/Change dialog box and in the Find Format: Section, click on the "Specify Attributes to Find" button and then choose the Paragraph style that you want to restrict your search to. Click OK. Then click change all. You should now have an end-it character at the end of only the stories for which the appropriate Paragraph Style is applied!