commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thiagoh <...@git.apache.org>
Subject [GitHub] commons-lang pull request: Adding unwrap and unwrapFull methods to...
Date Sun, 24 Apr 2016 17:18:14 GMT
GitHub user thiagoh opened a pull request:

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

    Adding unwrap and unwrapFull methods to StringUtils

    Adding the following methods from `StringUtils`:
    * `public static String unwrap(String str, char unwrapChar)`
    * `public static String unwrapFull(String str, char unwrapChar)`
    * `public static String unwrap(String str, String unwrapStr)`
    * `public static String unwrapFull(String str, String unwrapStr)`
    * `public static String unwrap(String str, String unwrapLeft, String unwrapRight)`
    * `public static String unwrapFull(String str, String unwrapLeft, String unwrapRight)`
    
    These methods unwraps (fully or not) the string parameter
    
    Usage:
    ```
    
    // public static String unwrap(String str, char unwrapChar)
    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\"'"
    
    // public static String unwrapFull(String str, char unwrapChar)
    StringUtils.unwrapFull("", '\0') = ""
    StringUtils.unwrapFull("xabx", 'x') = "ab"
    StringUtils.unwrapFull("xxxxxxabxxxxxx", 'x') = "ab"
    StringUtils.unwrapFull("\"ab\"", '\"') = "ab"
    StringUtils.unwrapFull("\"\"ab\"\"", '\"') = "ab"
    StringUtils.unwrapFull("'ab'", '\'') = "ab"
    StringUtils.unwrapFull("'x'ab'x'", '\'') = "x'ab'x"
    StringUtils.unwrapFull("''ab''", '\'') = "ab"
    StringUtils.unwrapFull("'''''ab'''''", '\'') = "ab"
    StringUtils.unwrapFull("''''x'ab'''''", '\'') = "x'ab'"
    StringUtils.unwrapFull("'ab''''", '\'') = "ab'''"
    
    // public static String unwrap(String str, String unwrapStr)
    StringUtils.unwrap("xxabxx", "xx") = "ab"
    StringUtils.unwrap("xxxxabxxxx", "xx") = "xxabxx"
    StringUtils.unwrap("xx xxabxx xx", "xx") = " xxabxx "
    StringUtils.unwrap("xxZxx", "xx") = "Z"
    StringUtils.unwrap("xxZxx", "x") = "xZx"
    StringUtils.unwrap("xzx xzx", "xzx") = " "
    StringUtils.unwrap("xxxx xxxx", "xx") = "xx xx"
    StringUtils.unwrap("'name'", "'") = "name"
    StringUtils.unwrap("''name''", "'") = "'name'"
    StringUtils.unwrap("'''name'''", "'") = "''name''"
    
    // public static String unwrapFull(String str, String unwrapStr)
    StringUtils.unwrapFull("xxabxx", "x") = "ab"
    StringUtils.unwrapFull("xx xxabxx xx", "xx") = " ab "
    StringUtils.unwrapFull("xxZxx", "xx") = "Z"
    StringUtils.unwrapFull("xzx xzx", "xzx") = " "
    StringUtils.unwrapFull("xxxx xxxx", "xx") = " "
    StringUtils.unwrapFull("'name'", "'") = "name"
    StringUtils.unwrapFull("''name''", "'") = "name"
    StringUtils.unwrapFull("'''name'''", "'") = "name"
    
    // public static String unwrap(String str, String unwrapLeft, String unwrapRight)
    StringUtils.unwrap("xxabxx", "x", "x") = "ab"
    StringUtils.unwrap("xx xxabxx xx", "xx", "xx") = " ab "
    StringUtils.unwrap("xxZxx", "xx", "xx") = "Z"
    StringUtils.unwrap("xxZxx", "xx", "yy") = "xxZxx" // no unwrap
    StringUtils.unwrap("xzx xzx", "xzx", "xzx") = " "
    StringUtils.unwrap("xxxx xxxx", "xx", "xx") = " "
    StringUtils.unwrap("xxxx xxxx", "xx", "yy") = "xxxx xxxx" // no unwrap
    StringUtils.unwrap("xxxxxxxxxxoutputxxxxxxxxxx", "xxxxx", "xxxxx") = "output"
    StringUtils.unwrap("%{name}", "%{", "}") = "name"
    StringUtils.unwrap("%{ name}", "%{", "}") = " name"
    StringUtils.unwrap("%{ name }", "%{", "}") = " name "
    StringUtils.unwrap(" %{ name }", "%{", "}") = "  name "
    StringUtils.unwrap("%{'name'}", "%{'", "'}") = "name"
    StringUtils.unwrap("%{' name'}", "%{'", "'}") = " name"
    StringUtils.unwrap("%{' name '}", "%{'", "'}") = " name "
    StringUtils.unwrap(" %{' name '}", "%{'", "'}") = "  name "
    StringUtils.unwrap("%{ 'name'}", "%{'", "'}") = "%{ 'name'}" // no unwrap
    StringUtils.unwrap("% {'name'}", "%{'", "'}") = "% {'name'}" // no unwrap
    StringUtils.unwrap("% { 'name'}", "%{'", "'}") = "% { 'name'}" // no unwrap
    
    // public static String unwrapFull(String str, String unwrapLeft, String unwrapRight)
    StringUtils.unwrapFull("xxabxx", "x", "x") = "ab"
    StringUtils.unwrapFull("xx xxabxx xx", "xx", "xx") = " ab "
    StringUtils.unwrapFull("xxZxx", "xx", "xx") = "Z"
    StringUtils.unwrapFull("xxZxx", "xx", "yy") = "xxZxx" // no unwrap
    StringUtils.unwrapFull("xzx xzx", "xzx", "xzx") = " "
    StringUtils.unwrapFull("xxxx xxxx", "xx", "xx") = " "
    StringUtils.unwrapFull("xxxx xxxx", "xx", "yy") = "xxxx xxxx" // no unwrap
    StringUtils.unwrapFull("xxxxxxxxxxoutputxxxxxxxxxx", "xxxxx", "xxxxx") = "output"
    StringUtils.unwrapFull("%{name}", "%{", "}") = "name"
    StringUtils.unwrapFull("%{ name}", "%{", "}") = " name"
    StringUtils.unwrapFull("%{ name }", "%{", "}") = " name "
    StringUtils.unwrapFull(" %{ name }", "%{", "}") = "  name "
    StringUtils.unwrapFull("%{'name'}", "%{'", "'}") = "name"
    StringUtils.unwrapFull("%{' name'}", "%{'", "'}") = " name"
    StringUtils.unwrapFull("%{' name '}", "%{'", "'}") = " name "
    StringUtils.unwrapFull(" %{' name '}", "%{'", "'}") = "  name "
    StringUtils.unwrapFull("%{ 'name'}", "%{'", "'}") = "%{ 'name'}" // no unwrap
    StringUtils.unwrapFull("% {'name'}", "%{'", "'}") = "% {'name'}" // no unwrap
    StringUtils.unwrapFull("% { 'name'}", "%{'", "'}") = "% { 'name'}" // no unwrap
    
    ```
    @britter I'm rebasing my old pull request #25 
    
    Could you check it again?


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

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

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

    https://github.com/apache/commons-lang/pull/136.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 #136
    
----
commit 6815bbd9f8792f44512ca2c5940940ba524bfc55
Author: Thiago Andrade <thiagoh@gmail.com>
Date:   2016-04-24T16:42:08Z

    adding unwrap and unwrapFull methods

commit 8eaf8912e8ef7ef1a5c22aa1a110016e339f8ac7
Author: Thiago Andrade <thiagoh@gmail.com>
Date:   2016-04-24T17:08:00Z

    unwrap and unwrapFull tests

----


---
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.
---

Mime
View raw message