You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by PascalSchumacher <gi...@git.apache.org> on 2016/05/08 10:22:01 UTC

[GitHub] commons-lang pull request: Adding unwrap and unwrapFull methods to...

Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/136#discussion_r62429812
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -8471,4 +8471,384 @@ public static String wrap(final String str, final String wrapWith) {
     
             return wrapWith.concat(str).concat(wrapWith);
         }
    +
    +    /**
    +     * <p>
    +     * Unwraps the String from unwrapChar char.
    +     * <p>
    +     * 
    +     * <p>
    +     * A {@code null} input String returns {@code null}.
    +     * </p>
    +     * 
    +     * <pre>
    +     * 
    +     * StringUtils.unwrap(null, *) = null
    +     * 
    +     * StringUtils.unwrap("", '\0') = ""
    +     * StringUtils.unwrap("xabx", 'x') = "ab"
    +     * StringUtils.unwrap("\"ab\"", '\"') = "ab"
    +     * StringUtils.unwrap("\"\"ab\"\"", '\"') = "\"ab\""
    +     * StringUtils.unwrap("'ab'", '\'') = "ab"
    +     * StringUtils.unwrap("''ab''", '\'') = "'ab'"
    +     * StringUtils.unwrap("'''ab'''", '\'') = "''ab''"
    +     * StringUtils.unwrap("'\"abcd\"'", '\'') = "\"abcd\""
    +     * StringUtils.unwrap("'\"abcd\"'", '\"') = "'\"abcd\"'"
    +     * 
    +     * </pre>
    +     * 
    +     * <p>
    +     * Pay attention when using this method. It unwraps the string from outside to inside the whole string.
    +     * For example: <pre> StringUtils.unwrap("'name' sometext 'name'", '\'') </pre> 
    +     * returns <pre>"name' sometext 'name"</pre> 
    +     * not <pre>"name sometext name"</pre>
    +     * </p>
    +     * 
    +     * @param str
    +     *            the String to be unwrapped, may be null
    +     * @param unwrapChar
    +     *            the char that will unwrap str from the left side and right side
    +     * @return wrapped String, {@code null} if null String input
    +     * @since 3.4
    --- End diff --
    
    I guess this should be `3.5`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---