Find a glyph based on the glyphs next to it

I want to find all instances of the glyph (with unicode value \x{f067}) which appears before and after glyphs that have a red character style.
I want to apply a character style to it

I want to find all instances of the glyph (with unicode value \x{f067}) which appears before and after glyphs that have a red character style.
I want to apply a character style to it
1. Apply the character style ‘red’ to all red text.
2. Apply the red honorific style to all the red honorific characters.
3. Apply the honorific style to all black honorific characters.
But to fix text that you already processed (or just in case the solution doesn’t work), here’s a script:
(function () {
var red = app.documents[0].characterStyles.item('red');
var honorific = app.documents[0].characterStyles.item('red honorific');
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = /.\h\x{f067}\h./.source;
var found = app.documents[0].findGrep();
for (var i = 0; i < found.length; i++) {
if (found[i].characters[0].appliedCharacterStyle === red
&& found[i].characters[-1].appliedCharacterStyle === red) {
found[i].characters[2].appliedCharacterStyle = honorific;
}
}
}());
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.