LinkShare_468x60v1

Tuesday, March 24, 2015

How to use Replace & ReplaceAll in Java

Replace character

String newstring = str1.replace("-",",");


Replace string

String newstring = str1.replaceAll("[a-z]","0");


Replace string only for first match

String newstring = str1.replaceFirst("[a-z]","0");

No comments:

Post a Comment