my goal is to “collect” all the words (sequence of letters or numbers or underscore and nothing else) beginning with a “target pattern” (for example “@@”).
I’m trying with something like
Pattern regex = Pattern.compile("(?-i)@@[A-Z0-9a-z]*");
document.getRange().replace(regex, new ReplaceHandler(), true);
and, in the ReplaceHandler class
System.out.println(“Found [” +repArgs.getMatchNode().getText() +"]");
The program prints out the “target word” and, in most cases, extra characters before the “@@” or at the end of the word or both).
The second step will be to delete (substitute with a space) them and EXACTLY them (I cannot delete any extra character).