How can I trim the leading or trailing characters from a string in java?
For example, the slash character \"/\" - I\'m not interested in spaces, and am looking to t
You could use a simple iteration if you want to remove the leading characters from a string :
String removeLeadingChar(String s, char c) { int i; for(i = 0; i < s.length() && s.charAt(i) == c; ++i); return s.substring(i); }
same logic applies if you want to remove any trailing char.
char