String line = "Pritom K Mondal"; line = line.replaceAll("(?s).", "X"); Will output: XXXXXXXXXXXXXXX
The
(?s)
doesn't match anything but sets the DOTALL
flag. String line = "Pritom K Mondal"; line = line.replaceAll("(?s).", "X"); Will output: XXXXXXXXXXXXXXX
(?s)
doesn't match anything but sets the DOTALL
flag. String cardNumber = "4444 3333 2222 111"); cardNumber = cardNumber.trim(); cardNumber = cardNumber.replaceAll("\\D+", ""); Output: 4444333322221111