// RegEx replace
function reReplace(str, reg, rep) {
	var s = unescape(str);
	var re = new RegExp(eval(unescape(reg)));
	return s.replace(re, unescape(rep));
}

// RegEx match
function reMatch(str, reg) {
	var s = unescape(str);
	var arr = s.match(eval(unescape(reg)));
	return encodeArray(arr);
}

// RegEx test
function reTest(str, reg) {
	//flash can't pass empty strings, any empty string will come through as the string value 'null'
	var s = unescape((str == 'null' ? '' : str));
	var rx = eval(unescape(reg));
	//document.getElementById('TraceOutput').innerHTML += (str + ', ' + reg + ', ' + rx.test(s) + '<br />');
	return rx.test(s);
}

// escape the values in the array because 
// ExternalInterface doesn't escape some properly
function encodeArray(arr) {
	for (var i=0; i<arr.length;i++) {
		arr[i] = encodeURIComponent(arr[i]);
	}
	return arr;
}
