Java has a native class to help with this. It is the RTFEditorKit.java.
Here is some sample code that will convert the message from RTF to plain text.
// THis function will take a string and convert RTF to text
function convertRtfToText(inputString) {
inputString = new java.lang.String(inputString);
/*jshint undef:false*/
var rtfEditorKit = new javax.swing.text.rtf.RTFEditorKit();
/*jshint undef:true*/
var rtfDocument = rtfEditorKit.createDefaultDocument();
rtfEditorKit.read(new java.io.ByteArrayInputStream(inputString.getBytes()), rtfDocument, 0);
return rtfDocument.getText(0, rtfDocument.getLength());
}
// convertRtfToText will take a string that has the RTF formatting and return
// the content without the RTF formmatting.
// This example will replace the entire message object
message.setNode('/', convertRtfToText(message.getNode('/')));
// This example will replace just the OBX-5 value
message.setNode('OBX-5', convertRtfToText(message.getNode('OBX-5')));