[
https://issues.apache.org/jira/browse/LANG-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alessandro Gallotta updated LANG-1213:
--------------------------------------
Summary: ordinalIndexOf may skip first occurrence when searched string is
longer than 1 char (was: ordinalIndexOf skipping first occurrence when
searched string is longer than 1 char)
> 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
>
> The method
> {code:java}
> private static int ordinalIndexOf(final CharSequence str, final CharSequence
> searchStr, final int ordinal, final boolean lastIndex)
> {code}
> 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)