Copy link to clipboard
Quick GREP question. If I do want to change this text:
Tendrá un nombre:<sup>3</sup> se llamará Manolo.
Tendrá un nombre<sup>3</sup>: se llamará
As you see, all I want is to place the two points (or a comma, o a dot) AFTER the super script. I can easily do this with this search/replace in GREP:
But the end result is this:
Tendrá un nombre3<sup>:</sup> se llamará Manolo
So, InDesign applies the superscript style to the replaced text.
… Do you talk about "notes"?
(^/) The Jedi
Sorry, the <sup></sup> are intended to mean superscript, but I don't know how to write superscript using the text editor in Adobe Help forums.
Here an screenshot:
Also, I want to search/replace any of these punctuation characteres: . : ; (hence the search for [.;:])
Anyway, thanks for the help.
Copy link to clipboard
I think FRIdNGE is asking if those are plain numeric characters or if they are footnote (or endnote) reference numbers. I'm guessing they are plain numeric characters because I can recreate the problem with your GREP Find/Change and it wouldn't work if they were footnote/endnote numbers. (Unless you just typed up a quick example to use here—let us know!)
Anyway, assuming they are characters, you could use your GREP string as is, but change the formatting to Character Style to [None], and define a GREP style to superscript the numbers.
Define a GREP style to superscript the numbers that preceed a colon, period or comma:
Set up your original Find/Change query and change the Character Format to [None].
Change all and the GREP style kicks in:
Copy link to clipboard
I take from your post that this superscript number is not a footnote that is done with InDesign's footnote feature or an endnote that is done with InDesign's endnote feature. And it could help to know if there is a character style or a GREP style applied to the superscript number, to the character before and after.
Let's play it safe; my guess is that you need two or perhaps three GREP Find/Change actions to solve the problem.
 First GREP Find/Change where I also included the white space character, a blank, after the superscript number:
Change to the first found group, the second one, the first again and then the third group:
Plus change the formatting of the found text to unique formatting, a text property that is nowhere else used in your document; could be a special condition from InDesign's Conditional Text feature. A screenshot from my German InDesign illustrates this idea where the Conditional Text panel is named "Bedingter Text". I created a condition named "Temp" with a yellow marker before I configured the Change with GREP:
 Second GREP Find/Change:
plus that special formatting, the condition named "Temp" from above.
Change: [No entry]
The result would be the text frame at the bottom of this screenshot:
 Get rid of that applied special condition "Temp" from the Conditional Text feature.
Find condition named "Temp".
Change to no condition.
( ACP )
PS: I know, that Barb answered while I am writing this; nevertheless I will post my suggestion; perhaps you can take out the one or the other idea from it.
I like Simplicity: just 1 click!
/* _FRIdNGE-0713_InvertText.jsx by FRIdNGE, Michel Allio (^/) The Jedi [31/05/2021] */ // .1 ==> 1. app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "[.,;:]\\d+"; myFound = app.activeDocument.findGrep(); for ( var f = 0 ; f < myFound.length ; f++ ) myFound[f].characters.move(LocationOptions.after, myFound[f]); app.findGrepPreferences = null; /* // 1. ==> .1 app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "\\d+[.,;:]"; myFound = app.activeDocument.findGrep(); for ( var f = 0 ; f < myFound.length ; f++ ) myFound[f].characters[-1].move(LocationOptions.before, myFound[f]); app.findGrepPreferences = null; */ alert( "Done! … [" + myFound.length + "]" + "\r\rby FRIdNGE, Michel Allio (^/) The Jedi [31/05/2021]" )
I've marked this as the correct answer, but a big THANK YOU to ALL, because all the answers are correct! (and its great to know all the possible solutions provided by you).
This one is fast and easy to implement (just place the script in your scripts panel and that's it), so I think it's the "more correct" of all. Great, simple and beautiful script, FRIdNGE! (and also like that you can comment the sencond part of the script to find/replace the oposite occurence!)
And also... if you replace this line:
app.findGrepPreferences.findWhat = "[.,;:]\\d+";
To this one (note, I've replaced the \\d for ~F):
app.findGrepPreferences.findWhat = "[.,;:]~F";
It will also work with footnotes!!!