home *** CD-ROM | disk | FTP | other *** search
-
- //
- // Removes spaces at the beginning and end of string
- //
- function fnStringRemoveOutterSpaces(szString)
- {
- var szResult;
- //
- // remove leading spaces
- var regexp = /^\s+/g;
- szResult = szString.replace(regexp, "");
- //
- // remove ending spaces
- regexp = /\s+$/g;
- szResult = szResult.replace(regexp, "");
- //
- return szResult;
- };
-
- //
- // Replaces all white spaces in the string with single space character
- //
- function fnStringDelimiterSingleSpace(szString)
- {
- var szResult;
- //
- var regexp = /\s+/g;
- szResult = szString.replace(regexp, " ");
- //
- return szResult;
- }
-
- //
- // Prepare string for comparision
- // - removes leading and ending spaces
- // - replaces inner white space with single space char
- // - convert string to lower case
- //
- function fnStringPrepareForCompare(szString)
- {
- var szResult = fnStringRemoveOutterSpaces(szString);
- szResult = fnStringDelimiterSingleSpace(szResult)
- szResult = szResult.toLowerCase();
- //
- return szResult;
- }
-
- //
- // Compares 2 strings. Returns true if identical, otherwise false
- //
- function fnStringEqual(szString1, szString2)
- {
- //
- // prepare string for comparision
- var szString1Ready = fnStringPrepareForCompare(szString1);
- var szString2Ready = fnStringPrepareForCompare(szString2);
- //
- // compare
- return (szString1Ready == szString2Ready);
- }
-