function preg_replace(what, by, str)
{
	console.log('Match ' + str + ' against ' + what + ' and replace with ' + by);
	var regex = new RegExp(what);
	var match = regex.exec(str);
	for (i = 0; i < match.length; i++)
	console.log(match[i]);
}

function friendlyURL(str)
{
	return str.replace(/&(.)(acute|cedil|circ|ring|tilde|uml);/, '$1').replace(/&amp;/, '&').replace(/([^a-z0-9]+)/gi, '-').replace(/^-*/, '').replace(/-*$/, '').toLowerCase();
}