You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Vincent Fumo (JIRA)" <ji...@apache.org> on 2010/12/08 19:02:02 UTC

[jira] Created: (LANG-666) StringUtils.stripEnd() using a '.' as an "any" character

StringUtils.stripEnd() using a '.' as an "any" character
--------------------------------------------------------

                 Key: LANG-666
                 URL: https://issues.apache.org/jira/browse/LANG-666
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.*
    Affects Versions: 2.5
         Environment: JAVA 6, mac os X
            Reporter: Vincent Fumo
            Priority: Minor


The documentation for stripEnd() indicates that the second parameter should be the string to stip from the end of the first paramater. This mostly works, but I think I found a case where it doesn't and that's when there is a period '.' character in the stripChars. It seems to be counting the period as a regex anychar. Example code :

		// trying to strip the cents from a dollar amount
		String result = StringUtils.stripEnd("120.00", ".00");
		System.out.println("Expected \"120\", got \"" + result + "\"");
		
		// maybe we should escape the dot?
		result = StringUtils.stripEnd("120.00", "\\.00");
		System.out.println("Expected \"120\", got \"" + result + "\"");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-666) StringUtils.stripEnd() using a '.' as an "any" character

Posted by "Vincent Fumo (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vincent Fumo updated LANG-666:
------------------------------

    Attachment: StringUtilsTest.java

sample code

> StringUtils.stripEnd() using a '.' as an "any" character
> --------------------------------------------------------
>
>                 Key: LANG-666
>                 URL: https://issues.apache.org/jira/browse/LANG-666
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.5
>         Environment: JAVA 6, mac os X
>            Reporter: Vincent Fumo
>            Priority: Minor
>         Attachments: StringUtilsTest.java
>
>
> The documentation for stripEnd() indicates that the second parameter should be the string to stip from the end of the first paramater. This mostly works, but I think I found a case where it doesn't and that's when there is a period '.' character in the stripChars. It seems to be counting the period as a regex anychar. Example code :
> 		// trying to strip the cents from a dollar amount
> 		String result = StringUtils.stripEnd("120.00", ".00");
> 		System.out.println("Expected \"120\", got \"" + result + "\"");
> 		
> 		// maybe we should escape the dot?
> 		result = StringUtils.stripEnd("120.00", "\\.00");
> 		System.out.println("Expected \"120\", got \"" + result + "\"");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LANG-666) StringUtils.stripEnd() using a '.' as an "any" character

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved LANG-666.
-----------------------

    Resolution: Invalid

The second parameter is not a String - it is the *set* of characters to strip.

So StringUtils.stripEnd("120.00", ".00") - which is the same as StringUtils.stripEnd("120.00", ".0") - results in "12" because there is a "0" on the end.

However, StringUtils.stripEnd("121.00", ".0") gives "121".

> StringUtils.stripEnd() using a '.' as an "any" character
> --------------------------------------------------------
>
>                 Key: LANG-666
>                 URL: https://issues.apache.org/jira/browse/LANG-666
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.5
>         Environment: JAVA 6, mac os X
>            Reporter: Vincent Fumo
>            Priority: Minor
>         Attachments: StringUtilsTest.java
>
>
> The documentation for stripEnd() indicates that the second parameter should be the string to stip from the end of the first paramater. This mostly works, but I think I found a case where it doesn't and that's when there is a period '.' character in the stripChars. It seems to be counting the period as a regex anychar. Example code :
> 		// trying to strip the cents from a dollar amount
> 		String result = StringUtils.stripEnd("120.00", ".00");
> 		System.out.println("Expected \"120\", got \"" + result + "\"");
> 		
> 		// maybe we should escape the dot?
> 		result = StringUtils.stripEnd("120.00", "\\.00");
> 		System.out.println("Expected \"120\", got \"" + result + "\"");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.