Hi Guys,
the short answer:
this isn’t possible.
The long answer:
If you deal with grep expressions, you must distinguish between literals (abc) and metacharacters (e.g. or ~|). As you see, there seems to be a difference in those kind of metacharacters. While everything with a “\” in front is a real regex-metacharacter, everything with a “~” is InDesign-stuff.
If you search for text or for grep, you search within a string. If there is already an indexed word, you will find an anchor for that word. This anchor is displayed within a string with a InDesign-metacharacter. But from a technical point of view, there is also an index entry generated internally.
So, if you search for strings, you can only change a string to a string but you cannot generate and index entry! To make things complicated: While you can insert in the change-field e.g. \r you will get a return, but if you insert \u (character-class shortcut for any uppercase letter), you end up with “\u” as literal. Same if you enter “~|”
We talked in another topic about Peter Kahrels index-script. This is based on a character style, but can also be rewritten to deal with find-results. I dreamed, that we have also scripts, that deal with imported lists.
Kai