Hi Jesuale,
the basic algorithm could be this:
[1] Run a GREP Find action and store the found texts to an array.
[2] Loop that array of results and check the parent of the found text snippets.
If the parent is a cell, do nothing and continue to the next found item.
If the parent is not a cell do a change to that found text.
Look up this discussion we recently had:
[JS] Problem with change grep with look behind/ahead and /K
Kasyan Servetsky, Mar 16, 2022
https://community.adobe.com/t5/indesign-discussions/js-problem-with-change-grep-with-look-behind-ahead-and-k/m-p/12818708#M469736
In a nutshell the code below should work for you with GREP Find/Change. Not intensively tested, though. That's your job. To make that work do the following:
[1] Do your settings in InDesign's GREP Find/Change normal user interface.
[2] Then as a second step run this ExtendScript (JavaScript) code:
/*
Posted by Uwe Laubender at the InDesign User Forum:
https://community.adobe.com/t5/indesign-discussions/don-t-search-inside-tables-or-skip-tables/m-p/12937086#M476815
*/
( function()
{
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
app.doScript
(
ignoreTables,
ScriptLanguage.JAVASCRIPT,
[],
UndoModes.ENTIRE_SCRIPT,
"Find/Replace GREP; Leave out Tables | SCRIPT"
);
function ignoreTables()
{
var txt, changed,
doc = app.activeDocument,
found = doc.findGrep(false);
for (var i = 0; i < found.length; i++)
{
// IGNORE TEXT IN TABLE CELLS:
if( found[i].parent.constructor.name == "Cell" ){ continue };
// TEXT OUTSIDE TABLE CELLS:
txt = found[i];
app.findGrepPreferences.findWhat = txt.contents;
changed = txt.changeGrep();
};
};
}() )
If the result is not to your liking you can undo the whole thing with one single undo that is reading:
"Find/Replace GREP; Leave out Tables | SCRIPT"
Thanks Kasyan Servetsky for providing the core part of the code.
Regards,
Uwe Laubender
( ACP )