[ 
https://issues.apache.org/jira/browse/LANG-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15199291#comment-15199291
 ] 

Alessandro Gallotta commented on LANG-1213:
-------------------------------------------

it seems it has been fixed at 
[3.4|https://commons.apache.org/proper/commons-lang/release-notes/RELEASE-NOTES-3.4.txt]
 with 
[this|https://git-wip-us.apache.org/repos/asf?p=commons-lang.git;a=commitdiff;h=e5a3039f7a1e727fca40db7357a9191b6a7cf41d]

> 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)

Reply via email to