commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Commented] (LANG-1231) StringUtils#indexOfAny() methods with start position argument
Date Wed, 12 Oct 2016 09:17:21 GMT


Bruno P. Kinoshita commented on LANG-1231:

You are right that there is no such method [~gsavinov]. So if you have the following code.

String s = "paralalelepipedo";
int i = StringUtils.indexOfAny(s, "p");

Would print 0, the first occurrence of 'p'.

>Well, java.lang.String.substring(int beginIndex) can be used, so maybe it's Ok to pass
substring as an argument.

That's correct as well.

String s = "paralalelepipedo";
int i = StringUtils.indexOfAny(s.substring(1), "p");

Would print 9, the then first occurrence of 'p' in the substring (i.e. aralalelepipedo). You
may have to account for the substring later (i.e. in the original string, the index would
be 10, not 9). But I think it would be better to use the substring for now. What do you think?

If you have other use cases for this, feel free to add a comment or send a pull request or
patch :-)


> StringUtils#indexOfAny() methods with start position argument
> -------------------------------------------------------------
>                 Key: LANG-1231
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.4
>            Reporter: Guram Savinov
>            Priority: Minor
>              Labels: string
> 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

View raw message