Originally posted by Anoop Chandran:
You may need to write a parser which looks for html tags and will take off if that is contained in the specified String.
I am looking for redymade parser that does the same. Are there any?
Hope you are getting the data from db as Blob.
You are right.
[ December 16, 2005: Message edited by: Chetan Parekh ]
I don't think you need to store HTML as Blob - Clob should be sufficient, which would make it easier to work with.
Originally posted by Michael Duffy:
I'd wonder why HTML is stored in a database at all. Sounds like a design where the view layer has penetrated all the way back to persistence - not a sound idea in my opinion.
We are developing content management system, where user can submit formatted content that we need to store in database.
String thisStringHasNoHtml = stringWithHtml.replaceAll("\\<.*?\\>","");
This will not work. E.g. "<abc>text</abc>" will be reduced to nothing, because most regexp packages perform greedy matching. That means that they match as far to the right as possible, and don't stop at the first possible match if a longer one is available.
Either use the non-greedy option if it is available, or a string like "\\<[^<]*?\\>", which prevents another opening angle bracket to be part of the match. It's probably better to replace by a space -and not the empty string-, so that words don't get joined inadvertently.