Relative Content

Tag Archive for c#regexopenxml

Replacing a sentence that has citations in a DOCX file as Track Changes

I trying to replace a sentence instead of old one (which has citations) in a DOCX document using OpenXmlRegex.Replace method. The thing is creating the regex of old sentence and using it for replace operation works well for the sentences that do not have citations like ….[12] but it crashes in replacement operations for citation case. I put the whole sentence with citation numbers too for regex generation. Later, I realized that citations has more than <w:t> content. Citations are seen inside of <w:instrText> tags in the XML of DOCX files.