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 8527d58063
commit 353f454fe0

View File

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