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.

7 Years
Discussion Span
Last Post by jaysean

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.