Hello forum,

I am wondering if it is possible to do a mark-up in free text by comparison with some string. Suppose I have a file with several sub-strings, one in each line. I have another file which contains the full text from where the sub-strings are generated. Is it possible to mak-up the source text with <found> </found> tags?

If possible please give the code snippet for this purpose.

Thanks in advance.

Recommended Answers

All 3 Replies

Make a document over that file, then just write:

doc.insertString(offset,"The String",null)

.

The easiest way to do :

JTextArea text = new JTextArea();
text.setText("Your string");
AbstractDocument doc = text.getDocument();
doc.insertString(offset,"The String",null)

Offset is the position from which to start.

Sounds like an exercise for indexOf() - find the string in the source, and build a new source:
"everything up to where found" + <tag> + foundString + </tag> + "everything after the end of the found string"

Thanks for the replies. I like NormR1's approach as I am thinking in the same lines. The process is like a "Find" and mark-up. Something more concrete will help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.