Aspose.Words.Range.Replace throw exception ArgumentOutOfRangeException with regexp

Description

Aspose.Words.Range.Replace throw exception ArgumentOutOfRangeException with regexp.

Env

  • Windows 10 .NET 4.7
  • Aspose.Words for .NET 22.12

Code

var doc = new Aspose.Words.Document(@"C:\Users\XCL\Desktop\15.docx");
doc.Range.Replace(new Regex("A*"), "");

Error Preview

Test File

15.docx (25.8 KB)

@xucongli1989 Thank you for reporting the problem to us. For a sake of correction it has been logged as WORDSNET-24783. We will keep you posted and let you know once it is resolved or we have more information for you.
Also, I suppose your goal is to match one or more "A". In this case you can use "A+" regular expression, which works as expected.

doc.Range.Replace(new Regex("A+"), "");

Thanks a lot, my goal is not to match A, it’s just as a demo for you instead of my complex regex.

1 Like

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