Improve How to Count the Number of Matches for a Regex? (#9788)

This commit is contained in:
Mona Mohamadinia
2020-08-02 20:06:13 +04:30
committed by GitHub
parent 95bf16a944
commit 01492a6508

View File

@@ -1,12 +1,11 @@
package com.baeldung.regex.countmatches;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit Test intended to count number of matches of a RegEx using Java 8 and 9.
@@ -65,7 +64,7 @@ public class CountMatchesUnitTest {
count++;
}
assertNotEquals(3, count);
assertEquals(2, count);
}
@Test