Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
.lfs_col0 {color : #000000;}
.lfs_col1 {color : #ff0000;}
.lfs_col2 {color : #00ff00;}
.lfs_col3 {color : #ffff00;}
.lfs_col4 {color : #0000ff;}
.lfs_col5 {color : #ff00ff;}
.lfs_col6 {color : #00ffff;}
.lfs_col7 {color : #ffffff;}
.lfs_col8, .lfs_col9 {color : #8a8a8a;}
 
var str = '^1[TC]\u00bbPete\u00ab';
document.body.innerHTML = LFSColours(str);
function LFSColours(str) {
  var parts = str.split(/(\^\d)/g).slice(1);
  var res = "";
  parts.forEach(function(el, i, arr) {
    (i % 2 === 0) ? arr[i] = el.slice(1) : res += '<span class="lfs_col' + arr[i-1] + '">' + el + '</span>';
  });
  return res;
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
PButcherpro
0viewers