Chris Kelly created LANG-811:
--------------------------------

             Summary: StringUtils.stripStart strips out too many characters 
                 Key: LANG-811
                 URL: https://issues.apache.org/jira/browse/LANG-811
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.*
    Affects Versions: 3.1, 3.0, 2.6, 2.5
         Environment: N/A
            Reporter: Chris Kelly


I have a String "Tag-TransactionId" for which I want to remove the leading 
"Tag-" leaving only "TransactionId". I thought I could use 
StringUtils.stripStart for this but when I do I get the string "ransactionId" 
instead. 

Below is a short method indicating the issue. 



 public static void main(String[] args) {
        
        String key = "Tag-TransactionId";

        String keyWithoutTag = StringUtils.stripStart(key, "Tag-");
        
        String expected = "TransactionId";

        System.out.println("Expected: " + expected + " but got: " + 
keyWithoutTag);
        
    }


I have tried repeating test on commons-lang from 2.5 upwards to the latest 
release all with the same behaviour. It looks like if the string to be removed 
has characters similar to the remaining string, the stripStart methods works 
incorrectly. It seems to be a case problem as well. If I use 
"Tag-transactionId" with stripStart it successfully returns "transactionId"

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to