import java.io.*;
public class Main {
public static void main(String args[]) {
String str = new String(" Jack Sparrow ");
System.out.println("String: "+str);
System.out.print("Result after removing leading and trailing spaces:" );
System.out.println(str.trim() );
}
}
String[] in = {
"01234", // "[1234]"
"0001234a", // "[1234a]"
"101234", // "[101234]"
"000002829839", // "[2829839]"
"0", // "[0]"
"0000000", // "[0]"
"0000009", // "[9]"
"000000z", // "[z]"
"000000.z", // "[.z]"
};
for (String s : in) {
System.out.println("[" + s.replaceFirst("^0+(?!$)", "") + "]");
}
StringUtils.stripStart(yourString,"0");