Test case details

Preparation Code

var string = 'The hexadecimal color code <strong><code>{hex}</code></strong> is a {shadeLightness} shade of <strong>{shade}</strong>. In the RGB color model <code>{hex}</code> is comprised of {red}% red, {green}% green and {blue}% blue. In the HSL color space <em><code>{hex}</code></em> has a hue of {hue} degrees, {saturation}% saturation and {lightness}% lightness. This color has an <em>approximate</em> wavelength of <strong>{wavelength} nm</strong>.';

Test cases

Test #1

result = mystring.split('.').join(' ');

Test #2

result = string.replace(/\{hex\}/g, '#0066cc');

Test #3

/** * ReplaceAll by Fagner Brack (MIT Licensed) * Replaces all occurrences of a substring in a string */ String.prototype.replaceAll = function( token, newToken, ignoreCase ) { var _token; var str = this + ""; var i = -1; if ( typeof token === "string" ) { if ( ignoreCase ) { _token = token.toLowerCase(); while( ( i = str.toLowerCase().indexOf( token, i >= 0 ? i + newToken.length : 0 ) ) !== -1 ) { str = str.substring( 0, i ) + newToken + str.substring( i + token.length ); } } else { return this.split( token ).join( newToken ); } } return str; }; string.replaceAll('{hex}', '#0066cc');