You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alessandro Gallotta (JIRA)" <ji...@apache.org> on 2016/03/17 11:24:33 UTC
[jira] [Created] (LANG-1213) ordinalIndexOf skipping first
occurrence when searched string is longer than 1 char
Alessandro Gallotta created LANG-1213:
-----------------------------------------
Summary: ordinalIndexOf skipping 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)