web stats
Mirth Community - View Single Post - Mirth Tools: User defined functions
View Single Post
  #14  
Old 05-17-2012, 05:07 AM
panickc panickc is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 127
panickc is an unknown quantity at this point
Default String Functions

Here's some string functions I use all the time, simple but effective. -cp

function startsWith(str, prefix) {
return str.indexOf(prefix) === 0;
}

function endsWith(str, suffix) {
return str.match(suffix+"$")==suffix;
}

function Left(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
function Right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
Reply With Quote