非法字符替换函数
2006-11-14 14:33
253 查看
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[f_replace]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[f_replace]
GO
/*--非法字符替换函数
去掉字符串中,小于32的字符
保留 TAB char(9)
换行 char(10)
回车 char(13)
如果上述字符也不需要,则将函数中的注释删除
--邹建 2004.09(引用请保留此信息)--*/
/*--调用示例
--调用函数进行替换处理的示例
declare @s varchar(10)
set @s='a '+'b'+char(11)+'c'
select dbo.f_replace(@s)
--*/
create function f_replace(
@str varchar(8000)
)returns varchar(8000)
as
begin
select @str=replace(@str,a,'')
from(select a=N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N''
--union all select N''--TAB char(9)
--union all select N'
--'--换行 char(10)
union all select N''union all select N''
--union all select N'
--'--回车 char(13)
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'
drop function [dbo].[f_replace]
GO
/*--非法字符替换函数
去掉字符串中,小于32的字符
保留 TAB char(9)
换行 char(10)
回车 char(13)
如果上述字符也不需要,则将函数中的注释删除
--邹建 2004.09(引用请保留此信息)--*/
/*--调用示例
--调用函数进行替换处理的示例
declare @s varchar(10)
set @s='a '+'b'+char(11)+'c'
select dbo.f_replace(@s)
--*/
create function f_replace(
@str varchar(8000)
)returns varchar(8000)
as
begin
select @str=replace(@str,a,'')
from(select a=N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N''
--union all select N''--TAB char(9)
--union all select N'
--'--换行 char(10)
union all select N''union all select N''
--union all select N'
--'--回车 char(13)
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'' union all select N''
union all select N'
相关文章推荐
- Oracle 使用TRANSLATE函数替换字符串中的字符
- asp 过滤非法字符函数
- 字符串替换空格: 请实现一个函数,把字符数组中的每个空格替换成“%20”。 例如输入“we are happy.”,则输出“we are happy.”
- PHP通用非法字符检测函数集锦
- 【C语言】请实现一个函数,把字符数组中的每个空格替换成“%20”
- 非法字符替换,防SQL注入(asp)
- 两款查找替换所选字符函数
- JS 字符串操作函数 往指定位置插入字符 删除指定位置字符 替换指定位置字符
- php 替换非法字符 保存到数据库
- ASP 非法字符过滤函数
- 过滤非法字符集函数一定程度上避免输入非法字符引起SQL语句的错误
- [C/C++]_[初级]_[标准库之几种算法库函数的运用,如字符串查找(字符个数查找)、分隔、删除、替换、排序、字符交换位置、大小写转换等等]
- javascript中使用replaceAll()函数实现字符替换的方法
- 实现一个函数,把字符数组中的每个空格替换成“%20”。 例如输入“we are happy.”,则输出“we%20are%20happy”
- JS 字符串操作函数 往指定位置插入字符 删除指定位置字符 替换指定位置字符
- 非法字符处理(替换)
- js正则替换多个字符,多个参数调用只有一个参数的函数
- 将字符串中的危险字符替换掉函数 ReplaceStr()
- 解决js函数replace禁止输入框输入非法字符,光标回到文字最后问题
- 几个范畴中的字符替换(正则表达式和函数的结合运用)