Answers for "how to remove space from string at last"

1

remove last space from line

Use either one of both next commands with sed 's/to_replace/replace/':
sed 's/ *$//' file
sed 's/[[:blank:]]*$//' file
Posted by: Guest on October-22-2020
5

string remove last character

public static String removeLastCharacter(String str) {   
	String result = null;   
    if ((str != null) && (str.length() > 0)) {      
    	result = str.substring(0, str.length() - 1);   
    }   
    
    return result;
}
Posted by: Guest on March-30-2020

Code answers related to "how to remove space from string at last"

Browse Popular Code Answers by Language