日期:2014-05-17 浏览次数:20554 次
declare @str varchar(200)
set @str='<option value="555.14879">安全情报与分析</option>'
declare @s varchar(100)
set @s=''
while(@str<>'')
begin
if patindex('%['+nchar(19968)+'-'+nchar(40891)+']%',substring(@str,1,1))<>0
set @s=@s+substring(@str,1,1)
set @str=stuff(@str,1,1,'')
end
with tb(a) as (
select '<optgroup label="安全·防护类" class="categoryParentItem">' union all
select '<option value="555.11961">保安</option>' union all
select '<option value="555.11769">海关与入境</option>' union all
select '<option value="555.11718">机场安全检查</option>' union all
select '<option value="555.11926">警察执法</option>' union all
select '<option value="555.11879">军事作战</option>' union all
select '<option value="555.11974">门店安全·防损</option>' union all
select '<option value="555.11914">其他(安全·防护类)</option>' union all
select '<option value="555.11805">消防与救援</option>' union all
select '<option value="555.11762">狱警</option>'
)
select *,
substring(a,convert(int,PATINDEX('%[吖-座]%',a)),len(a)-PATINDEX('%[吖-座]%',reverse(a))-PATINDEX('%[吖-座]%',a)+2)
from tb
declare @str varchar(200)
set @str='<option value="555.14879">安全情报与分析</option>'
declare @s varchar(100)
set @s=''
while(@str<>'')
begin
if PATINDEX('%[吖-座]%',substring(@str,1,1))>0
set @s=@s+substring(@str,1,1)
set @str=stuff(@str,1,1,'')
end
select @s
DECLARE @a TABLE(id INT,b VARCHAR(100))
INSERT @a SELECT 1,'<option value=""555.14879"">安全情报与分析</option>'
UNION ALL SELECT 2,'<option value=""555.11961">保安</option>'
UNION ALL SELECT 3,'<option value=""555.11769"">海关与入境</option&