You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2016/05/28 16:15:13 UTC

[jira] [Closed] (LANG-1213) ordinalIndexOf may skip first occurrence when searched string is longer than 1 char

     [ https://issues.apache.org/jira/browse/LANG-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pascal Schumacher closed LANG-1213.
-----------------------------------

> ordinalIndexOf may skip first occurrence when searched string is longer than 1 char
> -----------------------------------------------------------------------------------
>
>                 Key: LANG-1213
>                 URL: https://issues.apache.org/jira/browse/LANG-1213
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Alessandro Gallotta
>             Fix For: 3.4
>
>
> The method
> {code:java}
> private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) 
> {code}
> [source | https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html]
> at the line
> {code:java}
> 1028                index = CharSequenceUtils.indexOf(str, searchStr, index + searchStr.length());
> {code}
> is using as starting index for search the _index+searchStr.length()_ .In case where the _searchStr_ is a single character, the first run will start from index
> {code:java}
> -1+1 = 0
> {code}
> if the _searchStr_ is long N, it will start at N-1 index and if _str_ contains the _searchStr_ before N-1 it will miss it



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)