You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by luo zongle <lu...@hotmail.com> on 2023/05/10 03:46:39 UTC

[cli] Repeated substring problem

The commons cli project has repeatedly used substring here. Can I simplify it to one

Similar to the following


static String stripLeadingAndTrailingQuotes(String str) {
    final int length = str.length();
    String tmp;
    if (length > 1 && str.startsWith("\"") && str.endsWith("\"") && (tmp = str.substring(1, length - 1)).indexOf('"') == -1) {
        return tmp;
    }

    return str;
}



This is from before

[cid:image001.png@01D98334.87534660]