string msg = "123 test"; system.out.println(msg.replaceall("(?i)test", "****")); result: 123 ****
string msg = "123 te st"; system.out.println(msg.replaceall("(?i)test", "****")); result: "123 te st"
but want replace ignore spaces result: "123 ****"
what should change? "123 te st" "123 ****"
you should add blanks * wildcard regexp:
system.out.println(msg.replaceall("(?i)t *e *s *t", " ****"));
Comments
Post a Comment