You need to change the text of "[tel]" to your icon, and GREP Styles do not change text, they can only apply character styles.
So here is option #1: forget GREP styles and use find-and-change.
Option #2 is way, way more work (but then you can use GREP styles, and everything will happen automatically and all will be flowers and sunshine from then on):
1. Create a One-Character Font of your "[tel]" icon -- you can use the demo from IndyFont for this (http://www.indiscripts.com/post/2013/05/indyfont-1-1-public-pro-release-and-users-guide)
2. Assign the character code for "[" to this icon.
3. Add a GREP style that assigns your custom font to the character "[" when followed by 'tel':
4. Add a GREP style that assigns a blanking style to the part that should be invisible:
This character style should set a horizontal width of 1% and a fill color of "[None]".
5. Repeat for "[accom]"
Do you remember helping me with this same sort of problem a few weeks ago when I needed a custom square bullet?
I ended up making ligatures from the tags like <B> and <b> and even the word bullet and adjusting the side bearings, which would eliminate the need for look-behind and a second style to set a 1% width and [None] fill. Does the demo do ligatures? I've forgotten.
If not, it might be worth the price for the full version.
Peter, yes you can create a single ligature from the entire construction "[tel]" -- but, alas, not with the demo. To create a ligature, you *also* need the original characters in the same font -- and so you can't do that using the demo.
PeipiPepi does not mention what sort of icons this is about -- if they are simple monochromatic vector icons, you could experiment with the demo and see if you can get it to work. But since this uses a *font*, exactly like using a Wingdings or Dingbats font, you are automatically restricted to one color.
(That said: with the *full* version, you could create a separate "border" character with a width of zero, and design the next character so that it falls exactly into the center of this border. Then it's two characters, which you can color separately.)
(Also: the free demo is restricted to One Character Per One Font. For two icons, you need two fonts, which the demo happily allows; it's just a bit more cumbersome since you have to have separate character styles and GREP styles as well.)
Hi Jongware and Peter,
I should have been more specific (learning the Grep Ropes here) - I'd like to apply Grep Styles to text like [tel] and [accom] and use characters from Dingbat fonts as the icons. So assuming I can apply characters styles using Greps, this should be possible, shouldn't it?
apply Grep Styles to text like [tel] and [accom] and use characters from Dingbat fonts
On Find and Change dailgo box (grep)
Change to: ~c
Change to: ~c
Important note:copy the Dingbat character before click on change.
Grep STYLES can only change formatting, which is why switching to a different font with the correct glyph at that position will work, but they cannot change the glyph to some other character, i.e. a grep style cannot change the word cat to dog. For that you need Find/Change.
If you go with Find/Change, one option for the change field is to use formatted or unformatted contes from the clipboard, so it would be possible to simply copy the correct dingbat to the clipboard and then run the query, but this is not an automatic process that will happen as you type, the way a GREP style is.