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

Bruno P. Kinoshita commented on LANG-622:
-----------------------------------------

I had a look at LANG-622.patch and tried playing with lastIndex and 
replacing/simplifying the existing loops, but with no luck. 

The problem I found was in cases like lastIndexOfAnyBut('abcdd', new char[] 
{'b', 'd'}). My first implementation failed and returned the index of the first 
'd' (instead of the index of c)... maybe if I backtracked until the previous 
char wasn't another 'd' again... but I didn't think it was the best approach.

The loops are similar to what is done in indexOfAnyBut. Do you think maybe we 
can use this version? 

The only modifications I would do were add javadocs and a few more tests, as 
well as adding the @Test annotation to the new test methods. What do you think?

> StringUtils.lastIndexOfAnyBut() function desired
> ------------------------------------------------
>
>                 Key: LANG-622
>                 URL: https://issues.apache.org/jira/browse/LANG-622
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: david cogen
>            Priority: Minor
>             Fix For: Patch Needed
>
>         Attachments: LANG-622.patch, StringUtilslLastIndexOfAnyButTest.java
>
>
> class StringUtils needs the function lastIndexOfAnyBut()
> This would be like indexOfAnyBut() except searches from the end rather than 
> the beginning.
> It would be like lastIndexOfAny() except looks for a character other than 
> those in the string rather than for those in the string.
> This is the only one of the four combinations of "from beginning"/"from end" 
> and "for any"/"for any but" that is not provided.
> Interestingly, the class header doc. mentions "LastIndexOfAnyBut" but the 
> function does not exist - even as a private, as determined by class 
> introspection.
> (This is not a frivolous request. I actually did need this function and ended 
> up having to code a search loop.)



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to