[
https://issues.apache.org/jira/browse/LANG-1231?focusedWorklogId=511608&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511608
]
ASF GitHub Bot logged work on LANG-1231:
----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Nov/20 22:47
Start Date: 13/Nov/20 22:47
Worklog Time Spent: 10m
Work Description: kinow commented on a change in pull request #644:
URL: https://github.com/apache/commons-lang/pull/644#discussion_r523271674
##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -2854,6 +2854,39 @@ public static int indexOfAny(final CharSequence cs,
final String searchChars) {
return indexOfAny(cs, searchChars.toCharArray());
}
+ /**
+ * <p>Search a CharSequence to find the first index of any
+ * character in the given set of characters starting with
+ * a given index.</p>
+ *
+ * <p>A {@code null} String will return {@code -1}.
+ * A {@code null} search string will return {@code -1}.</p>
+ *
+ * <pre>
+ * StringUtils.indexOfAny(null, 0, *) = -1
+ * StringUtils.indexOfAny("", 0, *) = -1
+ * StringUtils.indexOfAny(*, 0, null) = -1
+ * StringUtils.indexOfAny(*, 0, "") = -1
+ * StringUtils.indexOfAny("zzabyycdxx", 0, "za") = 0
+ * StringUtils.indexOfAny("zzabyycdxx", 0, "by") = 3
+ * StringUtils.indexOfAny("aba", 0, "z") = -1
+ * StringUtils.indexOfAny("aba", 1, "a") = 1
+ * StringUtils.indexOfAny("aba", -1, "a") = -1
+ * </pre>
+ *
+ * @param cs the CharSequence to check, may be null
+ * @param beginIndex the start position to search
+ * @param searchChars the chars to search for, may be null
+ * @return the index of any of the chars, -1 if no match,null input or
the beginIndex smaller than 0
+ * @since 3.12
+ */
+ public static int indexOfAny(final CharSequence cs, int beginIndex, final
String searchChars) {
+ if (isEmpty(cs) || isEmpty(searchChars) || beginIndex < 0) {
+ return INDEX_NOT_FOUND;
+ }
+ return indexOfAny(cs.toString().substring(beginIndex),
searchChars.toCharArray());
Review comment:
Maybe we should just document that it's not supported for now. Or spend
some more time making it support special locales/chars?
```java
Locale turkish = Locale.forLanguageTag("tr");
assertEquals(1, StringUtils.indexOfAny("TITLE".toLowerCase(turkish), 0,
"i")); // error, -1 returned
```
WDYT @garydgregory ?
@arturobernalg if you have any thoughts too, but in the meantime, could you
squash your commits? Your change is very well written, and concise. But there
are now 13 commits due to review feedback. We can squash it too when merging,
but it'd be simpler if you could do it, please.
Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 511608)
Time Spent: 1h 40m (was: 1.5h)
> StringUtils#indexOfAny() methods with start position argument
> -------------------------------------------------------------
>
> Key: LANG-1231
> URL: https://issues.apache.org/jira/browse/LANG-1231
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Affects Versions: 3.4
> Reporter: Guram Savinov
> Priority: Minor
> Labels: string
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> There is no StringUtils#indexOfAny() methods with start position argument,
> which would search for specified characters from the specified position.
> Please add it.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)