public class Tstees {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
while (true) {
if(scanner.hasNext()){
String str = scanner.next();
String ss = RemoveBrackets(str, '<', '>');
System.out.println("输入的是"+ss);
}
}
}
public static String RemoveBrackets(String Content, char myFront, char myBack)
{
String myResult = "";
//-----
int Count = 0;
for (int i = 0; i < Content.length(); i++)
{
if (Count == 0)
{
if (Content.charAt(i) == myFront)
{
Count++;
} else
{
//在括号外
myResult += Content.charAt(i);
}
} else
{
//在括号内
if (Content.charAt(i) == myFront)
{
Count++;
} else if (Content.charAt(i) == myBack)
{
Count--;
}
}
}
//-----
return myResult;
}
}