function(str, symbol, replace) {
			var i = 0;
			var il = str.length;
			var sl = symbol.length;
			var matchCount = 0;
				
			while (i < il) {
				if (str.charAt(i) == '\\') {
					// escaped symbol, skip next character
					i += sl + 1;
				} else if (str.substr(i, sl) == symbol) {
					// have match
					var curSl = sl;
					matchCount++;
					var newValue = replace;
					if (_.isFunction(replace)) {
						var replaceData = replace(str, symbol, i, matchCount);
						if (replaceData) {
							curSl = replaceData[0].length;
							newValue = replaceData[1];
						} else {
							newValue = false;
						}
					}
					
					if (newValue === false) { // skip replacement
						i++;
						continue;
					}
					
					str = str.substring(0, i) + newValue + str.substring(i + curSl);
					// adjust indexes
					il = str.length;
					i += newValue.length;
				} else {
					i++;
				}
			}
			
			return str;
		}
function(str, symbol, replace) {
			var i = 0;
			var il = str.length;
			var sl = symbol.length;
			var matchCount = 0;
				
			while (i < il) {
				if (str.charAt(i) == '\\') {
					
					i += sl + 1;
				} else if (str.substr(i, sl) == symbol) {
					
					var curSl = sl;
					matchCount++;
					var newValue = replace;
					if (_.isFunction(replace)) {
						var replaceData = replace(str, symbol, i, matchCount);
						if (replaceData) {
							curSl = replaceData[0].length;
							newValue = replaceData[1];
						} else {
							newValue = false;
						}
					}
					
					if (newValue === false) { 
						i++;
						continue;
					}
					
					str = str.substring(0, i) + newValue + str.substring(i + curSl);
					
					il = str.length;
					i += newValue.length;
				} else {
					i++;
				}
			}
			
			return str;
		}
function ( str , symbol , replace ) { var i = 0 ; var il = str . length ; var sl = symbol . length ; var matchCount = 0 ; while ( i < il ) { if ( str . charAt ( i ) == '\\' ) { // escaped symbol, skip next character i += sl + 1 ; } else if ( str . substr ( i , sl ) == symbol ) { // have match var curSl = sl ; matchCount ++ ; var newValue = replace ; if ( _ . isFunction ( replace ) ) { var replaceData = replace ( str , symbol , i , matchCount ) ; if ( replaceData ) { curSl = replaceData [ 0 ] . length ; newValue = replaceData [ 1 ] ; } else { newValue = false ; } } if ( newValue === false ) { // skip replacement i ++ ; continue ; } str = str . substring ( 0 , i ) + newValue + str . substring ( i + curSl ) ; // adjust indexes il = str . length ; i += newValue . length ; } else { i ++ ; } } return str ; }
Replaces unescaped symbols in <code>str</code>. For example, the '$' symbol
will be replaced in 'item$count', but not in 'item\$count'.
@param {String} str Original string
@param {String} symbol Symbol to replace
@param {String} replace Symbol replacement. Might be a function that
returns new value
@return {String}
Replaces unescaped symbols in <code > str< / code > . For example the $ symbol will be replaced in item$count but not in item \ $count .