Find and replace that is going forward does not work. I saw on some posts (on this forum) suggestion use false for isForward parameter. That does not work for me. I need to process document forward as I am adding some indexes and direction should be as that. Is there any work around for this ?
Code snippet :
Regex regex = new Regex(@"something", RegexOptions.IgnoreCase);
doc.Range.Replace(regex, new ReplaceEvaluatorAndIncrementCounters(), true);
this snippet fails with :
System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message=StartIndex cannot be less than zero.
Parameter name: startIndex
Source=mscorlib
ParamName=startIndex
StackTrace:
at System.String.Remove(Int32 startIndex, Int32 count)
at ? . (ReplacingArgs )
at ? . ()
at Aspose.Words.Range.Replace(Regex pattern, IReplacingCallback handler, Boolean isForward)
at CSharp.Programming_Documents.Find_and_Replace.FindAndHighlight.Run2() in f:\Programming\Aspose_Words_NET-master\Aspose_Words_NET-master\Examples\CSharp\Programming-Documents\Find-Replace\FindAndHighlight.cs:line 48
at CSharp.RunExamples.Main() in f:\Programming\Aspose_Words_NET-master\Aspose_Words_NET-master\Examples\CSharp\RunExamples.cs:line 101
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Here are the code snippets and document in attachment. For description, I have in my document several occurrences of special tags that I want to replace with counters. <*NumberCounter*> - number counter, starts from 1 and counts further <*LetterCounter*> - starts from A, B, C, and goes further
I expect to process document top-down. And to have valid replacements. When I set true in Replace method I got exception. When I switch back to false, it works but I will have bottom up replacements that do not work for me.
We are able to reproduce the issue. It has been logged into our issue tracking system as WORDSNET-12530. We will keep you updated on this issue in this thread.
Thanks for being patient. Regarding WORDSNET-12530, our product team has completed the analysis of this issue and the root cause has been identified. Currently, they are on the final stage of reviewing/testing all code changes that were done in the scope of this issue. We will inform you via this thread as soon as your issue is resolved.
Thanks for your inquiry. We have a good news i.e. our product team has resolved this issue (WORDSNET-12530) and they have planned to include the fix to your issue in next 15.11.0 release of Aspose.Words. We will inform you via this thread as soon as next release containing the fix to this issue is published in next few days.