Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Removing tags from a string

Oct 12 2009 2:28PM by Madhivanan   

In http://ask.sqlteam.com, a question was asked about removing the comments from the HTML 
template

The comments have the following pattern

{/*}comment{*/}

The comments can be nested too

The task is to remove all the comments

Here is my solution

declare @string varchar(8000) ,@data varchar(8000)

select @string = 'AaaA{/*}XxxX{/*}YyyyY{*/}ZzzzZ{*/}BbbB{/*}CCC{*/}DdD'

select @string=replace(replace(@string, '{/*}','~{/*}'),'{*/}','~{*/}')

declare @t table(id int identity(1,1),data varchar(8000)) 
insert into @t(data)
select 
        substring(@string, n, charindex('~', @string + '~', n ) - n)
from 
( 
        select number as n from master..spt_values where type='p' 
) numbers 
where 
        substring( '~' + @string, n, 1 ) = '~' 

--Method 1

set @string='' select @string =@string+data from 
(
    select data from @t where id=1 
    union all
    select substring(data,5,len(data)) from @t 
    where (data like '{*/}%' and id%2=1)
) as t 
select @string 

--Method 2

select @string =''

select 
        @string =@string +substring(t2.data,5,len(t2.data)) 
from 
        @t as t1 inner join @t as t2 on t1.id+1=t2.id
where 
        t2.data like '{*/}%' and t2.id%2=1 and t2.data<>'{*/}'

select @string 

Tags: t-sql, sql_server, clean_data, regular_expression,


Madhivanan
3 · 40% · 12936
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Removing tags from a string " rated 5 out of 5 by 1 readers
Removing tags from a string , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]