How to use Regex.Matches().count


#1

I am not able to import Ragex and matches.please help me to solve this.
int totalCount = Regex.Matches(plainText, toBeMatched ).Count;


#2

@rabin.samanta

Thanks for your inquiry. Please use the following 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);