removeLeft, replace lowercase return string in case-insensitive call
johnsdouglass opened this issue · comments
A useful library, thanks!
removeLeft and replace work in a way I wouldn't expect because they call toLower in the case-insensitive case.
For example,
Strman.removeLeft("This HAS A THIS IN FRONT", "THIS ", false)
returns "has a this in front". I would expect it to return "HAS A THIS IN FRONT".
Perhaps you could check for startsWith in a case-insensitive way, then remove the first N characters of value, where N is the length of prefix.
Strman.replace("One and two and THREE and Four", "and", "&", false)
returns "one & two & three & four". I would expect it to return "One & two & THREE & Four".
I haven't tested this, but maybe for the replace function you could copy the replace function in the String class and specify Pattern.CASE_INSENSITIVE (and maybe Pattern.UNICODE_CASE).
removeRight works in what I would call the correct way:
Strman.removeRight("Remove the END at the end", " END", false)
returns "Remove the END at the".
@johnsdouglass thanks for your feedback. I have resolved this issue and will release a new version.