php的preg#u replace函数的c#.net等价物是什么?
const ALLOW_VALUES = '[^a-z0-9à áâäèéêëìÃîïòóôöùûŵýÿyÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÅ´YÃ]';
public function streetTownHash($data, $hashCheck = false, $updateRecord = false)
{
foreach($data as $key=>$value){
try{
$value = mb_convert_case($value, MB_CASE_LOWER, "UTF-8");
} catch(Exception $e) {
echo "Requires extension=php_mbstring.dll enabled ! - $e";
}
$valueConcat .= preg_replace('/'.self::ALLOW_VALUES.'/','',$value);
}
$streetTownHash = sha1($valueConcat);
....
编辑:现在是这样。
private readonly SHA1 hash = SHA1.Create();
private readonly Regex PunctuationStripper = new Regex(@"[^a-z0-9à áâäèéêëìÃîïòóôöùûŵýÿyÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÅ´YÃ]", RegexOptions.IgnoreCase);
public string HashString(string value)
{
value = value.ToLower();
value = PunctuationStripper.Replace(value, string.Empty);
var bytes = ASCIIEncoding.UTF8.GetBytes(value);
var hashed = hash.ComputeHash(bytes);
return ASCIIEncoding.UTF8.GetString(hashed);
}
编辑:
正则表达式是否也需要更改?