int count = doc.getRange().replace(“hello”, “hello”, options);
without above method how to count occurrence
Thanks for your inquiry. Please use the following code to get desired results. Hope, this helps.
string plainText = doc.Range.Text;
string toBeMatched = "hello";
int totalCount = Regex.Matches(plainText, toBeMatched ).Count;
Please use updated code to get desired results. Hope, this helps.
String plainText = doc.getRange().getText();
String toBeMatched = "Aspose.Words";
Pattern pattern = Pattern.compile(toBeMatched);
Matcher matcher = pattern.matcher(plainText);
int count = 0;
while (matcher.find()) {
count++;
}
System.out.println("Total Count is: " + count);
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.