commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Benson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-811) StringUtils.stripStart strips out too many characters
Date Tue, 10 Jul 2012 16:14:35 GMT

    [ https://issues.apache.org/jira/browse/LANG-811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410472#comment-13410472
] 

Matt Benson commented on LANG-811:
----------------------------------

To be helpful:  I think the functionality you're looking for is expressed by {{StringUtils#removeStart()}}
:)
                
> 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: 2.5, 2.6, 3.0, 3.1
>         Environment: N/A
>            Reporter: Chris Kelly
>              Labels: api-change
>
> 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

        

Mime
View raw message