web stats
Mirth Community - View Single Post - Search for alpha characters and delete OBX
View Single Post
Old 05-13-2019, 12:26 PM
Brad_AZ Brad_AZ is offline
OBX.1 Kenobi
Join Date: Mar 2018
Location: Arizona, USA
Posts: 27
Brad_AZ is on a distinguished road

I couldn't get anything from your expression other than -1 so I went in a different direction. This seems to work for me with your message and others that I mocked up.

var setID = 1;                                                             // sets intial value for SET ID

for ( var a=0; a < msg['OBX'].length(); a++ )

     var alpha = /[a-z]/;                                                  // defines a-z as values in expression
	var str = msg['OBX'][a]['OBX.5']['OBX.5.1'].toString().toLowerCase(); // converts alpha to lowercase
	if (str.match(alpha)) {                                               // looks for a-z in string
		 delete msg['OBX'][a];
		 a = a-1;                                                        // resets the counter back one because you deleted the segment
else {
msg['OBX'][a]['OBX.1']['OBX.1.1'] = setID;                                // populates SET ID starting with 1
setID ++                                                                  // increments set ID
SIG|1|Brad|Mirth Certified Interface Analyst^Cancer Treatment Centers of America

Last edited by Brad_AZ; 05-13-2019 at 12:29 PM.
Reply With Quote