Sidebar

Splitting OBX 5 on /.br/ but there are some special characters that I need to eliminate

0 votes
18 views
asked Aug 1 by surya-p-7473 (200 points)

Hi,

Currently I am splitting OBX into multiple OBX at /.br/ (OBX-5) but the source is sending ??, ???, ? followed by some of the /.br/ and I need to eliminate them as well.

 

Example: \.br\??? Content.\.br\? Content2.\.br\Content3

 

The current result is 

OBX|||||??? Content.

OBX? Content2.

OBX|||||?Content3

So the current script I am using is and I need to remove the ?? and ? and ??? at the begining of the OBX segment or at the begining of OBX5 specifically.

var obxString = message.getNode('OBX-5'); var obxArray = StringUtils.splitByWholeSeparator(obxString, '\\.br\\');

message.removeAllNodes('OBX');

for (var i = 0; i < obxArray.length; i++) {
   if (StringUtils.length(obxArray[i]) > 0) {
      message.addChild('/', 'OBX', 'OBX||TX|' + obxArray[i].trim());
      
   }
}

var segCount = message.getCount('OBX');
for (var j = 1; j <= segCount; j++) {
   message.setNode('OBX-1', j + '', j);}
 

 

1 Answer

0 votes

The stringUtils.replace() will take care of the ? that are coming over from the source system. 

var obxString = StringUtils.replace(message.getNode('OBX-5'), '?', '');
var obxArray = StringUtils.splitByWholeSeparator(obxString, '\\.br\\');

message.removeAllNodes('OBX');

for (var i = 1; i < obxArray.length; i++) {
   if (StringUtils.length(obxArray[i]) > 0) {
      message.addChild('/', 'OBX', 'OBX||TX|' + obxArray[i].trim());

   }
}

var segCount = message.getCount('OBX');
for (var j = 1; j <= segCount; j++) {
   message.setNode('OBX-1', j + '', j);}

answered Aug 1 by amanda-w-3695 (4,340 points)
...