Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Extract certain Strings from an existing String?

807606Jun 5 2007 — edited Jun 6 2007
I have a program which is reading text from files and marking certain words with <span> tags. I then display them in a JSP page. My issue is that the text from a file may contain HTML tags that I want the browser to render as text and not analyze them, but my <span> tags have to be rendered properly.

I was thinking that in some way I should split up the String into sections based on any tag matching <span ...> (I have specific information in those tags) and all the other parts maybe replace < with < and > with %gt;

So for example if I have
Today was a rainy <span type="dayofweek" id="1">Friday</span>.

I'd like an array of Strings
"Today was a rainy"
"<span type="dayofweek" id="1">"
"Friday"
"</span>"
Is there some type of tokenizing method that I can use to get this type of result?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2007
Added on Jun 5 2007
5 comments
258 views