Three Strings Want Replace Date Strings Using Replaceall Date Number Middle Strings Couldn Q37069650

I have three Strings and I want to replace the date from stringsby using replaceall. but the date number is in middle of thestrings and I couldn’t figure out how to to do that.

String s1 = “Proce.Arr.20190416.server10”;
String s2 = “Proce.Arr.20190416.ball10”;
String s3 = “Proce.Arr.20190416.ball23”;

I want to replace 20190416 from each strings by “”; I trieds1.replaceall(“[^0-9]”, “”); However, it printout wrong.


Solution


String s1 = “Proce.Arr.20190416.server10”;

String s2 = “Proce.Arr.20190416.ball10”;

String s3 = “Proce.Arr.20190416.ball23”;

System.out.println(s1.replaceAll(“20190416″,””));

System.out.println(s2.replaceAll(“20190416″,””));

System.out.println(s3.replaceAll(“20190416”, “”));

===================================================================
SEE OUTPUT
6 <terminated> Array2d [Java Application] /l Proce.Arr..server10 Proce.Arr..bal110 Proce.Arr..bal123 public static void main(
Thanks, PLEASE COMMENT if there is any concern.

6 <terminated> Array2d [Java Application] /l

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.