We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Search word in entire document


i’ve already implemented a document Search for paragraph (ReplaceEvaluetorFind ref = …)

All works great if the word in in Paragraph, but this kind of search dont works for table (for example):

how can i search for a word (and get the entire paragraph) whe this is inside a table (all document table).

In shot, i would like to search a word (and get the entire paragraph) in the whole document.

Hi Francesco,

Thanks for your
inquiry. Please use the following code example to achieve your
requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");
Pattern regex = Pattern.compile("find text", Pattern.CASE_INSENSITIVE);
doc.getRange().replace(regex, new MyReplaceEvaluator(), false);
doc.save(MyDir + "Out.docx");
private class MyReplaceEvaluator implements IReplacingCallback
    public int replacing(ReplacingArgs e) throws Exception
        Node currentNode = e.getMatchNode();
        Paragraph para = (Paragraph)currentNode.getParentNode();
        return ReplaceAction.SKIP;