Created
April 25, 2019 06:33
-
-
Save vanjikumaran/ac1f03c7549a2935201c093ff7aea1d8 to your computer and use it in GitHub Desktop.
Regex based Char replacement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Pattern; | |
import java.util.regex.Matcher; | |
public class RegexBasedTest { | |
private static final Pattern PASSWORD_PATTERN = Pattern.compile("[a-zA-z0-9]{3}"); | |
private static final String uuid = "b02fb649-797b-440b-9aa9-f3294ed0ce73"; | |
public static void main(String[] args) { | |
for (int i = 0; i < Integer.MAX_VALUE; ++i) { | |
String masked = replaceChar(uuid); | |
} | |
} | |
private static String replaceChar(String uuid) { | |
final Matcher pwdMatcher = PASSWORD_PATTERN.matcher(uuid); | |
return pwdMatcher.replaceFirst("****"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment