You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rocky D. Pulley (JIRA)" <ji...@apache.org> on 2010/04/12 20:07:49 UTC
[jira] Created: (LANG-615) add indexesOf methods to StringUtils
add indexesOf methods to StringUtils
------------------------------------
Key: LANG-615
URL: https://issues.apache.org/jira/browse/LANG-615
Project: Commons Lang
Issue Type: New Feature
Components: lang.*
Reporter: Rocky D. Pulley
Priority: Minor
Adding methods to StringUtils which support returning an array of indexes of a search string.
The following code would return int [0, 18, 45, 57]:
{code}
String s = "This is a test of this string which contains this a lot. this";
int[] idxs = indexesOfIgnoreCase(s, "this");
for (int i=0; i<idxs.length; i++)
{
System.out.println("Pos: " + idxs[i]);
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (LANG-615) add indexesOf methods to StringUtils
Posted by "Rocky D. Pulley (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rocky D. Pulley updated LANG-615:
---------------------------------
Attachment: StringUtils_indexOf_diff.java
I have attached the methods added to the StringUtils class for this feature. I hope that I am doing this correctly as this is my first time trying to contribute.
> add indexesOf methods to StringUtils
> ------------------------------------
>
> Key: LANG-615
> URL: https://issues.apache.org/jira/browse/LANG-615
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Reporter: Rocky D. Pulley
> Priority: Minor
> Attachments: StringUtils_indexOf_diff.java
>
>
> Adding methods to StringUtils which support returning an array of indexes of a search string.
> The following code would return int [0, 18, 45, 57]:
> {code}
> String s = "This is a test of this string which contains this a lot. this";
>
> int[] idxs = indexesOfIgnoreCase(s, "this");
>
> for (int i=0; i<idxs.length; i++)
> {
> System.out.println("Pos: " + idxs[i]);
> }
> {code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Closed: (LANG-615) add indexesOf methods to StringUtils
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell closed LANG-615.
------------------------------
Resolution: Won't Fix
Closing as Won't Fix in favour of using regex.
> add indexesOf methods to StringUtils
> ------------------------------------
>
> Key: LANG-615
> URL: https://issues.apache.org/jira/browse/LANG-615
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Reporter: Rocky D. Pulley
> Priority: Minor
> Attachments: StringUtils_indexOf_diff.java
>
>
> Adding methods to StringUtils which support returning an array of indexes of a search string.
> The following code would return int [0, 18, 45, 57]:
> {code}
> String s = "This is a test of this string which contains this a lot. this";
>
> int[] idxs = indexesOfIgnoreCase(s, "this");
>
> for (int i=0; i<idxs.length; i++)
> {
> System.out.println("Pos: " + idxs[i]);
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (LANG-615) add indexesOf methods to StringUtils
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881108#action_12881108 ]
Henri Yandell commented on LANG-615:
------------------------------------
Thanks Rocky - sorry for the long delay in replying.
Looking at this, my thoughts run along the lines that:
. o O ( Bit of a pain to largely duplicate the indexOfIgnoreCase )
. o O ( Arrays aren't the nicest API, really you'd want some kind of iterable concept )
. o O ( That's what the Matcher API is in regex )
So I think this is a case where the regex API is preferable to more code. Something like:
Matcher m = Pattern.compile("this").matcher(s);
while(m.find()) {
System.out.println("Pos: " + m.start());
}
> add indexesOf methods to StringUtils
> ------------------------------------
>
> Key: LANG-615
> URL: https://issues.apache.org/jira/browse/LANG-615
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Reporter: Rocky D. Pulley
> Priority: Minor
> Attachments: StringUtils_indexOf_diff.java
>
>
> Adding methods to StringUtils which support returning an array of indexes of a search string.
> The following code would return int [0, 18, 45, 57]:
> {code}
> String s = "This is a test of this string which contains this a lot. this";
>
> int[] idxs = indexesOfIgnoreCase(s, "this");
>
> for (int i=0; i<idxs.length; i++)
> {
> System.out.println("Pos: " + idxs[i]);
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (LANG-615) add indexesOf methods to StringUtils
Posted by "Rocky (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881161#action_12881161 ]
Rocky commented on LANG-615:
----------------------------
thanks for the reply, I never knew about this use of the regex API.
> add indexesOf methods to StringUtils
> ------------------------------------
>
> Key: LANG-615
> URL: https://issues.apache.org/jira/browse/LANG-615
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Reporter: Rocky D. Pulley
> Priority: Minor
> Attachments: StringUtils_indexOf_diff.java
>
>
> Adding methods to StringUtils which support returning an array of indexes of a search string.
> The following code would return int [0, 18, 45, 57]:
> {code}
> String s = "This is a test of this string which contains this a lot. this";
>
> int[] idxs = indexesOfIgnoreCase(s, "this");
>
> for (int i=0; i<idxs.length; i++)
> {
> System.out.println("Pos: " + idxs[i]);
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.