File tree Expand file tree Collapse file tree
java-strings/src/test/java/com/baeldung/string Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class StringContainingCharactersUnitTest {
1111
1212 private static final Pattern [] inputRegexes = new Pattern [4 ];
1313
14- private static final String regex = "^(?=.*?\\ p{Lu})(?=.*?[ \\ p{L}&&[^ \\ p{Lu}]] )(?=.*?\\ d)" + " (?=.*?[`~!@#$%^&*()\\ -_=+\\ \\ \\ |\\ [{\\ ]};:'\" ,<.>/?]).*$" ;
14+ private static final String regex = "^(?=.*?\\ p{Lu})(?=.*?\\ p{Ll} )(?=.*?\\ d)(?=.*?[`~!@#$%^&*()\\ -_=+\\ \\ |\\ [{\\ ]};:'\" ,<.>/?]).*$" ;
1515
1616 static {
1717 inputRegexes [0 ] = Pattern .compile (".*[A-Z].*" );
@@ -101,21 +101,36 @@ public void givenInvalidStrings_whenChecking_thenNotCorrect() {
101101 @ Test
102102 public void givenSingleRegex_whenMatchingCorrectString_thenMatches () {
103103 String validInput = "Ab3;" ;
104- assertTrue (Pattern .compile (regex ).matcher (validInput ).matches ());
104+ assertTrue (Pattern
105+ .compile (regex )
106+ .matcher (validInput )
107+ .matches ());
105108 }
106109
107110 @ Test
108111 public void givenSingleRegex_whenMatchingWrongStrings_thenNotMatching () {
109112 String invalidInput = "Ab3" ;
110- assertFalse (Pattern .compile (regex ).matcher (invalidInput ).matches ());
113+ assertFalse (Pattern
114+ .compile (regex )
115+ .matcher (invalidInput )
116+ .matches ());
111117
112118 invalidInput = "Ab;" ;
113- assertFalse (Pattern .compile (regex ).matcher (invalidInput ).matches ());
119+ assertFalse (Pattern
120+ .compile (regex )
121+ .matcher (invalidInput )
122+ .matches ());
114123
115124 invalidInput = "A3;" ;
116- assertFalse (Pattern .compile (regex ).matcher (invalidInput ).matches ());
125+ assertFalse (Pattern
126+ .compile (regex )
127+ .matcher (invalidInput )
128+ .matches ());
117129
118130 invalidInput = "b3;" ;
119- assertFalse (Pattern .compile (regex ).matcher (invalidInput ).matches ());
131+ assertFalse (Pattern
132+ .compile (regex )
133+ .matcher (invalidInput )
134+ .matches ());
120135 }
121136}
You can’t perform that action at this time.
0 commit comments