Merge pull request #19560 from owen-mc/java/add-stringreplaceallwithnonregex-test

Java: Add test showing correct usage
This commit is contained in:
Owen Mansel-Chan
2025-05-22 15:07:58 +01:00
committed by GitHub
2 changed files with 2 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ public class Test {
String s1 = "test";
s1 = s1.replaceAll("t", "x"); // NON_COMPLIANT
s1 = s1.replaceAll(".*", "x"); // COMPLIANT
s1 = s1.replace("t", "x"); // COMPLIANT
}
}

View File

@@ -3,5 +3,6 @@ public class Test {
String s1 = "test";
s1 = s1.replaceAll("t", "x"); // $ Alert // NON_COMPLIANT
s1 = s1.replaceAll(".*", "x"); // COMPLIANT
s1 = s1.replace("t", "x"); // COMPLIANT
}
}