/* -------------------------------- ** FUNCTION: ** fnRemoveNameFromNameValueString ** DESCRIPTION: ** This function removes the text of the name ** item in a name=value format string. ** For Example: ** ------------ ** Ff the name, value string is ** employee=joseph ** Then the function should return the text string ** '=joseph' or just 'joseph' depending on whether ** the 'bRemoveDelimiter' parameter is true. ** ** An assumption is made that the name field cannot ** contain any 'escaped' characters, such as the ** delimiter character. Escaping means to place another ** character (such as '\' normally) in front of a ** particular character that would other wise be ** interpreted incorrectly by some program. ** For Example: ** ------------ ** If the name value string is something like... ** surf\=board\=type = billabong ** The function will return the string ** =board\=type = billabong ** even though the equals sign in this case was 'escaped' ** in a kind of traditional sense. ** Also: ** surf-board-type ' billabong = good' ** will return ** = good' ** even though from some points of view it really shouldnt ** These comments are also applicable to the function ** fnGetNameFromNameValueString ** DEPENDENCIES: ** fnStripLeadingSpaceFromString ** SEE ALSO: ** DATE: ** -------------------------------- */ function fnRemoveNameFromNameValueString( sString, sDelimiter, bRemoveDelimiter) { if (sDelimiter == null) { sDelimiter = "="; } if (bRemoveDelimiter == null) { bRemoveDelimiter = true; } if (sString == null) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- write out some nasty error message //-- somewhere, mortally insulting the programmer //-- for incurring such an ridiculous error return -1; } var sReturn = sString; var iIndexOfDelimiter = -1; //-->-->-->-->-->-->-->-->-->-->-->--> //-- I am removing initial spaces so that the //-- space character can be used as a delimiter //-- because lets face it, the space character //-- is really a perfectly acceptable delimiter //-- but very rarely do you want leading spaces //-- to be interpreted as delimiters //-- E.G //-- type star //-- should work even if there a initial spaces. sReturn = fnStripLeadingSpaceFromString(sReturn); iIndexOfDelimiter = sReturn.indexOf(sDelimiter); //-->-->-->-->-->-->-->-->-->-->-->--> //-- Case: //-- The delimiter is not found in the //-- 'name/value' string. if (iIndexOfDelimiter == -1) { return sReturn; } sReturn = sReturn.substring(iIndexOfDelimiter, sReturn.length); if (bRemoveDelimiter == true) { sReturn = sReturn.substring(sDelimiter.length, sReturn.length); } return sReturn; } //-- fnRemoveNameFromNameValueString()