Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
2.5, 2.6, 3.0, 3.1
-
None
-
N/A
Description
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"