Java examples for java.lang:String HTML
Strips HTML tags from text
/**/* w ww .jav a 2s. com*/ * Copyright (c) 2005-2006 Aptana, Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html. If redistributing this code, * this entire header must remain intact. */ import java.text.MessageFormat; public class Main{ /** * EMPTY */ public static final String EMPTY = ""; /** * Strips HTML tags from text * * @param text * Text to strip * @return the text, minus any tags */ public static String stripHTML(String text) { if (text == null) { return null; } String tempText = text.replaceAll("<p>", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ return tempText.replaceAll("\\<.*?\\>", StringUtils.EMPTY); //$NON-NLS-1$ } }