function escCtrlChars(str)
{
return str.replace(/[\0\t\n\v\f\r\xa0'"!-]/g,
function(c) {
return '!' + c.charCodeAt(0) + '!';
});
}
Ok this is a function that replaces control characters from a string with another string starting and ending with !
My question is. Is c
the character found while going through str
?
If so how can you mimic this function in PHP.?
function escCtrlChars($str)
{
return preg_replace('/[\0\t\n\v\f\r\'\"!-]/i', "!".ord($str[0])."!", $str);
}
I had this in PHP but i realize now it's wrong (since it uses the string and not the character found)