Java tutorial
//package com.java2s; public class Main { private final static String STRSQBRACKETSTART = "[", STRSQBRACKETEND = "]", STRCURLYSTART = "{", STRCURLYEND = "}", STRGT = ">", STRLT = "<"; /** * Removes '[' and ']' from beginning and end of a String, * but only if both are present. * @param s * @return */ public static String chopBraces(String s) { if (s.startsWith(STRSQBRACKETSTART) && s.endsWith(STRSQBRACKETEND)) return s.substring(1, s.length() - 1); return s; } }