How to find text surrounded by square brackets


Hi I am using Aspose.Words to find and replace certain strings enclosed in brackets eg. I need to replace all occurrences of [EMP_NAME] with some employee name. I am attempting to use doc.Range.Replace. The square brackets are not being recognized – would you be able to help me to phrase my search?
I’ve been trying something like:
doc.Range.Replace("[EMPLOYEE_FULL_NAME]", “emp”, true, true).
Thank you!



Thanks for your inquiry. Please use the following code example to get the desired output.

Document mainDoc = new Document(MyDir + "in.docx");
mainDoc.Range.Replace(new Regex("\\[EMP_NAME\\]"),"name of employee", new FindReplaceOptions());
mainDoc.Save(MyDir + "output.docx");


Thank you so much!