You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by iashok22 <gi...@git.apache.org> on 2017/09/26 09:54:22 UTC

[GitHub] commons-lang pull request #290: Added string methods

GitHub user iashok22 opened a pull request:

    https://github.com/apache/commons-lang/pull/290

    Added string methods

    1. indexOfAll - Finds and returns all the indexes of given character
    2. isAnagram - Tells whether given string is anagram with another string

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/iashok22/commons-lang master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/290.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #290
    
----
commit 18e4f8173eb6c1ea3cc11548b043e927544be084
Author: Ashok <ai...@paypal.com>
Date:   2017-08-31T06:36:55Z

    Added string methods

----


---

[GitHub] commons-lang issue #290: Added string methods

Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:

    https://github.com/apache/commons-lang/pull/290
  
    The anagram method belongs in commons-text IMO.


---

[GitHub] commons-lang pull request #290: Added string methods

Posted by Abrasha <gi...@git.apache.org>.
Github user Abrasha commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/290#discussion_r141814183
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -9245,5 +9245,39 @@ public static String unwrap(final String str, final char wrapChar) {
                 index += Character.charCount(result[i]);
             }
             return result;
    +    }    
    +    
    +    /**
    +     * <p>Finds index of all the occurences of given search key found in source string.
    +     * </p>
    +     * @param source
    +     * @param searchKey
    +     * @return list of integer of indexes.
    +     */
    +    public static List<Integer> indexOfAll(final String source, final Character searchKey) {
    +    	if(source == null || source.length() == 0 || searchKey == null ) {
    +    		return null;
    +    	}
    +    	List<Integer> indexList = new ArrayList<>();
    +		for(int i = 0 ; i < source.length() ; i++) {
    +			if(searchKey.equals(source.charAt(i))) {
    +				indexList.add(i);
    +			}
    +		}
    --- End diff --
    
    Could you fix the indentation please? Let it be properly aligned.


---

[GitHub] commons-lang pull request #290: Added string methods

Posted by iashok22 <gi...@git.apache.org>.
Github user iashok22 closed the pull request at:

    https://github.com/apache/commons-lang/pull/290


---

[GitHub] commons-lang issue #290: Added string methods

Posted by britter <gi...@git.apache.org>.
Github user britter commented on the issue:

    https://github.com/apache/commons-lang/pull/290
  
    I agree with @garydgregory. @chtompki WDYT?


---