Identifying the Paragraph and edit/replace/delete

Hi Aspose Team ,

Can you please let me know ,how can i identify a current paragraph using a placeholder .I have a gaint document ,which may contain over huge number paragraphs ,as per word ,ever other sentence after a line break is a paragraph ,so considering can you please let me know whats the best way to do it .Without time consuming ,

Placeholder is like a unique identifier . ##ParaGraphItenditfier##

So get the paragraph which contrains that identifier and should be able to replace that paragraph withh another paragraph including the properities ,Delete that paragrpah or append a new sentence at the end of that paragraph


Hi Krishna,

Thanks for your inquiry. Please see attached sample Word document and try executing the following code:

Document doc = new Document(MyDir + @"input.docx");
doc.Range.Replace(new Regex("##ParaGraphItenditfier##"), new ReplaceHandler(), false);
doc.Save(MyDir + @"out.docx");
private class ReplaceHandler: IReplacingCallback
    ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
        Paragraph parentPara = e.MatchNode.ParentNode as Paragraph;
        if (parentPara != null)
            // --> append new text to this paragraph
            // Run newText = new Run(e.MatchNode.Document, "new text added");
            // parentPara.Runs.Add(newText);
            // --> replace that paragraph withh another paragraph including the properities
            // Paragraph newPara = new Paragraph(e.MatchNode.Document);
            // Run someText = new Run(e.MatchNode.Document, "some text added");
            // newPara.Runs.Add(someText);
            // parentPara.ParentNode.InsertBefore(newPara, parentPara);
            // parentPara.Remove();
            // --> remove paragraph
        return ReplaceAction.Skip;

I hope, this helps.

Best regards,