假设以下定义:
/// <summary>
/// Replaces each occurrence of sPattern in sInput with sReplace. This is done
/// with the CLR:
/// new RegEx(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace).
/// The result of the replacement is the return value.
/// </summary>
[SqlFunction(IsDeterministic = true)]
public static SqlString FRegexReplace(string sInput, string sPattern,
string sReplace)
{
return new Regex(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace);
}
如果为 sInput
传入长度大于4000的 nvarchar(max)
值,则该值将被截断(即调用此UDF的结果为 nvarchar(4000)
,而不是 nvarchar(max)
)。