JSFiddle - React, Tailwind, and code Playground

by Daedalus

JavaScript

str = ['foo from:2012-01-01 bar', 'foo from: 2012-01-01 bar', 'foo title:2012-01-01 bar', 'foo title: 2012-01-01 bar'];

for (var i = 0; i < str.length; i++) {
    var rep = str[i].replace(/(\w+:\s?)([a-z0-9-]+)/i, function(match, $1) {
        console.log(arguments);
        return $1 + 'replaced';
    });
    console.log(rep);
}