String (String value) { int counter = 0; int index = 0; boolean contMode = false; loop: while (index < value.length()) { switch (value.charAt(index)) { case '*': if (!contMode) { break loop; } break; case 'L': case 'T': if (!contMode) { contMode = true; } case '[': case '+': case '-': break; default: if (!contMode) { break loop; } break; case '<': counter++; break; case '>': counter--; break; case ';': if (counter == 0) { break loop; } } index++; } return value.substring(0, index + 1); }