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

Free Support Forum - aspose.com

Range.Replace does not throwing RegexMatchTimeoutException in .Net

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();
        <<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>>

        FindReplaceOptions options = new FindReplaceOptions(FindReplaceDirection.Backward);
        options.UseLegacyOrder = true;
        options.MatchCase = false;
        doc.Range.Replace(rgx, String.Empty, options);
    catch (RegexMatchTimeoutException e)

@N.Kononovich Thank you for reporting this problem to us. I have managed to reproduce it. For a sake of correction the issue has been logged as WORDSNET-23428. We will keep you informed and let you know once it is resolved.

The issues you have found earlier (filed as WORDSNET-23428) have been fixed in this Aspose.Words for .NET 22.3 update also available on NuGet.