Range.Replace does not return correct count

Hello @AndreyN ! :slight_smile:
I am also stuck with a similar issue, but the method replace() that you suggested is deprecated now.
It says : The method replace(String, String, boolean, boolean) from the type Range is deprecated.

I tried this : int count = doc.getRange().replace(regex, “Test”, options);
But, am not getting correct count,

Can you please help me with this?

@Kushal.20,

Please ZIP and attach your input Word document and piece of source code here for testing. We will then investigate the issue on our end and provide you more information.

doc.getRange().replace(regex, “Test”, options);
int count = callback.mMatchNumber;

class xyz implements IReplacingCallback {

public int mMatchNumber;

public int replacing(ReplacingArgs e) throws Exception {
	  mMatchNumber++;
	  return ReplaceAction.SKIP;
	    
	
}

}

I tried this approach and it worked for me !
Anyways, thanks a lot @awais.hafeez for your co-operation ! :slight_smile:

@Kushal.20,

It is great that you were able to find what you were looking for. Please let us know any time you have any further queries.