stripStart and stripEnd methods changed to fulfill their javadoc.
Passing in strip("-+-+FOO---", "+-") will result in FOO.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@136934 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java
index f2c7ad2..e73517e 100644
--- a/src/java/org/apache/commons/lang/StringUtils.java
+++ b/src/java/org/apache/commons/lang/StringUtils.java
@@ -80,7 +80,7 @@
  * @author <a href="mailto:ed@apache.org">Ed Korthof</a>
  * @author <a href="mailto:rand_mcneely@yahoo.com>Rand McNeely</a>
  * @author <a href="mailto:scolebourne@joda.org>Stephen Colebourne</a>
- * @version $Id: StringUtils.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
+ * @version $Id: StringUtils.java,v 1.2 2002/07/19 04:04:45 bayard Exp $
  */
 public class StringUtils {
 
@@ -1001,7 +1001,7 @@
     }   
 
     /**
-     * Strip any of a supplied string (first letter) from the end of a String..
+     * Strip any of a supplied string from the end of a String..
      * If the strip string is null, whitespace is stripped.
      * 
      * @param str  the string to remove characters from
@@ -1019,8 +1019,7 @@
                 end--;
             }
         } else {
-            char chr = strip.charAt(0);
-            while ((end != 0) && (str.charAt(end - 1) == chr)) {
+            while ((end != 0) && (strip.indexOf(str.charAt(end - 1)) != -1)) {
                 end--;
             }
         }
@@ -1028,7 +1027,7 @@
     }
 
     /**
-     * Strip any of a supplied string (first letter) from the start of a String.
+     * Strip any of a supplied string from the start of a String.
      * If the strip string is null, whitespace is stripped.
      * 
      * @param str  the string to remove characters from
@@ -1050,7 +1049,7 @@
             }
         } else {
             char chr = strip.charAt(0);
-            while ((start != sz) && (str.charAt(start) == chr)) {
+            while ((start != sz) && (strip.indexOf(str.charAt(start)) != -1)) {
                 start++;
             }
         }
diff --git a/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java b/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
index 587ea47..abe89dc 100644
--- a/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
+++ b/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
@@ -63,7 +63,7 @@
  *
  * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
  * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
- * @version $Id: StringUtilsTrimEmptyTest.java,v 1.1 2002/07/19 03:35:55 bayard Exp $
+ * @version $Id: StringUtilsTrimEmptyTest.java,v 1.2 2002/07/19 04:04:45 bayard Exp $
  */
 public class StringUtilsTrimEmptyTest extends TestCase {
     private static final String FOO = "foo";
@@ -134,6 +134,7 @@
         String fooRightDots = FOO+".........";
 
         assertEquals("", StringUtils.strip(""));
+        assertEquals("", StringUtils.strip("        "));
         assertEquals(FOO, StringUtils.strip(foo2Space));
         assertEquals(FOO, StringUtils.strip(foo2Dots, "."));
         assertEquals(FOO, StringUtils.strip(fooRightSpace));
@@ -157,6 +158,10 @@
         assertEquals(fooLeftSpace, StringUtils.stripEnd(fooLeftSpace, " "));
         assertEquals(fooLeftDots, StringUtils.stripEnd(fooLeftDots, "."));
 
+        assertEquals(FOO, StringUtils.strip(". . . . ."+FOO+". . ", " ."));
+        assertEquals("-."+FOO, StringUtils.strip(". . . . -."+FOO+". . ", " ."));
+        assertEquals(FOO, StringUtils.strip("..  .."+FOO+".. ", " ."));
+
         // test stripAll method, merely an array version of the above strip
         String[] empty = new String[0];
         String[] fooSpace = new String[] { foo2Space, fooLeftSpace, fooRightSpace };