Assuming following definition:
/// <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);
}
Passing in a nvarchar(max)
value for sInput
with a length > 4000 will result in the value being truncated (i.e. the result of calling this UDF is nvarchar(4000)
as opposed to nvarchar(max)
.