Java examples for java.lang:String Pad
remove Right Pad from String
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String str = "java2s.com"; String pad = "com"; System.out.println(removeRightPad(str, pad)); }//from w ww . j ava 2 s. c om public static String removeRightPad(String str, String pad) { while (str.endsWith(pad)) { str = str.substring(0, str.lastIndexOf(pad)); } return str; } }