You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (JIRA)" <ji...@apache.org> on 2016/10/12 09:17:21 UTC

[jira] [Commented] (LANG-1231) StringUtils#indexOfAny() methods with start position argument

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

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

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

{code}
String s = "paralalelepipedo";
int i = StringUtils.indexOfAny(s, "p");
System.out.println(i);
{code}

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.

{code}
String s = "paralalelepipedo";
int i = StringUtils.indexOfAny(s.substring(1), "p");
System.out.println(i);
{code}

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

Cheers

> 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
>
> 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
(v6.3.4#6332)