Java tutorial
//package com.java2s; /************************************************************************************** * Copyright (C) 2012 Lisa park, Inc. All rights reserved. * http://www.lisa-park.com * * E-Mail: alexmy@lisa-park.com * * ---------------------------------------------------------------------------------- * * The software in this package is published under the terms of the GPL license * * a copy of which has been included with this distribution in the license.txt file. * * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * **************************************************************************************/ public class Main { public synchronized static String clean(String string) { StringBuilder cleanStr = new StringBuilder(); Character lookFor = '<'; for (Character ch : string.toCharArray()) { if (ch == lookFor) { lookFor = lookFor == '<' ? '>' : '<'; cleanStr.append(ch); } else if (lookFor == '>') { cleanStr.append(ch); } } return cleanStr.toString(); } }