Hi! I’m using Aspose.Words 21.3 for .Net and it’s seems like Method Range.Replace does not throwing RegexMatchTimeoutException. There is small example:
static void Main(string[] args)
{
string pattern = @"<<MAIN(?'ItemProperties'[:](<<(?<LEVEL>)|>>(?<-LEVEL>)|(?!<<|>>).*?)+(?(LEVEL)(?!)))?>>.*?<<MAIN_END>>";
Regex rgx = new Regex(pattern, RegexOptions.None, TimeSpan.FromSeconds(1));
var doc = new Document();
doc.FirstSection.Body.AppendParagraph(@"<<QUOTE_ITEMS>>
<<NESTED_PRODUCTS>>
<<MAIN:CONDITION(Hardware)>> <<MAIN_CONTENT>>...Parent (root) Item Information...<<MAIN_CONTENT_END>><<MAIN_END>><<MAIN:CONDITION(Software)>><<MAIN_CONTENT>>...Child Item Information...<<MAIN_CONTENT_END>>
<<LI:CONDITION(Operating System)>><<LI _CONTENT>>...Line Child Item Information...<<LI _CONTENT_END>><<LI _END>> <<NESTED_PRODUCTS_END>>
<<QUOTE_ITEMS_END>>");
try
{
FindReplaceOptions options = new FindReplaceOptions(FindReplaceDirection.Backward);
options.UseLegacyOrder = true;
options.MatchCase = false;
doc.Range.Replace(rgx, String.Empty, options);
}
catch (RegexMatchTimeoutException e)
{
Console.WriteLine("Exception!");
}
}