xxxxxxxxxx
# subString(int start, int end);
String a = "Hello!";
b = a.subString(0,a.length()-1) #Remove the last String
# b should be "Hello" then
xxxxxxxxxx
public class RemoveParticularCharacter
{
public static void main(String[] args)
{
String strInput = "Hello world java";
System.out.println(removeCharacter(strInput, 6));
}
public static String removeCharacter(String strRemove, int r)
{
return strRemove.substring(0, r) + strRemove.substring(r + 1);
}
}
xxxxxxxxxx
System.out.println(
"a\u0000b\u0007c\u008fd".replaceAll("\\p{Cc}", "")
); // abcd
xxxxxxxxxx
public extractLetters(String str){
String result="";
for(int i= 0; i< str.length; i++){
if(Character.isLetter(str.charAt(i))){
result+=str.charAt(i);
}
}
xxxxxxxxxx
String str = "Grepper Answer"; // For eg : removing 5th element
str = str.substring(0,5) + str.substring(5+1); // "e"
System.out.println(str) //Output : Greppr Answer