Sunday, July 4, 2010

Trim Functions


I'll admit that working with Mirth was my first real exposure to Javascript. So the first time I needed them, I was surprised that there exist no trim functions.

Turns out this was something I was needing here and there, so instead of remembering the regex for the replace function I just created 3 small Code Templates for trim functions.

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