web stats
Mirth Community - View Single Post - Mirth Tools: User defined functions
View Single Post
Old 04-17-2012, 10:43 AM
upstart33 upstart33 is offline
Mirth Guru
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 461
upstart33 is on a distinguished road

3. Misc. Trim functions
Purpose: Sometimes, you need to do some trimming of strings. If you do not feeling like memorizing Regex, you can use something along the lines of the following.

function trim(in_str) {
    return new String(in_str).replace(/^\s+|\s+$/g,"");
function ltrim(in_str) {
    return new String(in_str).replace(/^\s+/,"");
function rtrim(in_str) {
    return new String(in_str).replace(/\s+$/,"");

Now, the function can be called within a transformer or mapper step:
var fname= trim(msg['patient_first'].toString());
Reply With Quote