public BinaryString trim ( BinaryString trimStr ) { if ( trimStr == null ) { return null ; } return trimLeft ( trimStr ) . trimRight ( trimStr ) ; }
Walk each character of current string from both ends remove the character if it is in trim string . Return the new substring which both ends trim characters have been removed .