/**
stripped = stripped.replaceAll("™", "(TM)");
stripped = stripped.trim();
}
<<<<<<< HEAD
}
return stripped;
}
=======
}
return stripped;
}
* Removes all of the HTML tags from a given string.
* Note: this is a very simplistic implementation
* and will most likely not work with complex HTML.
* Note: for actual conversion of HTML tags into regular
* strings have a look at {@link ERXSimpleHTMLFormatter}
* @param s html string
* @return string with all of its html tags removed
*/
// FIXME: this is so simplistic it will break if you sneeze
public static String removeHTMLTagsFromString(String s) {
StringBuffer result=new StringBuffer();
if (s != null && s.length()>0) {
int position=0;
while (position",position);
if (indexOfClosingTag!=-1) {
position= indexOfClosingTag +1;
} else {
result.append(s.substring(position, s.length()));
position=s.length();
}
}
}
return ERXStringUtilities.replaceStringByStringInString(" "," ",result.toString());
}
/**
* Returns the value stripped from HTML tags if escapeHTML is false.
* This makes sense because it is not terribly useful to have half-finished tags in your code.
* Note that the "length" of the resulting string is not very exact.
* FIXME: we could remove extra whitespace and character entities here
* @return value stripped from tags.
*/
public static String strippedValue(String value, int length) {
if(value == null || value.length() < 1)
return null;
StringTokenizer tokenizer = new StringTokenizer(value, "<", false);
int token = value.charAt(0) == '<' ? 0 : 1;
String nextPart = null;
StringBuffer result = new StringBuffer();
int currentLength = result.length();
while (tokenizer.hasMoreTokens() && currentLength < length && currentLength < value.length()) {
if(token == 0)
nextPart = tokenizer.nextToken(">");
else {
nextPart = tokenizer.nextToken("<");
if(nextPart.length() > 0 && nextPart.charAt(0) == '>')
nextPart = nextPart.substring(1);
}
if (nextPart != null && token != 0) {
result.append(nextPart);
currentLength += nextPart.length();
}
token = 1 - token;
}
return result.toString();
}
>>>>>>> 529a29409b31b724ba233885a6e376864461cdc4
/**
* @deprecated use {@link #stripHtml(String, boolean)}
*/ |