[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知1]
[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知2] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知3] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知4] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知5] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知6] 将上面字符串,转换成 <a href=/upload/newstxt/2010961573965111.doc>通知1</a>
<a href=/upload/newstxt/2010961573965111.doc>通知2</a>
<a href=/upload/newstxt/2010961573965111.doc>通知3</a>
<a href=/upload/newstxt/2010961573965111.doc>通知4</a>
<a href=/upload/newstxt/2010961573965111.doc>通知5</a>
<a href=/upload/newstxt/2010961573965111.doc>通知6</a>
[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知2] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知3] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知4] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知5] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知6] 将上面字符串,转换成 <a href=/upload/newstxt/2010961573965111.doc>通知1</a>
<a href=/upload/newstxt/2010961573965111.doc>通知2</a>
<a href=/upload/newstxt/2010961573965111.doc>通知3</a>
<a href=/upload/newstxt/2010961573965111.doc>通知4</a>
<a href=/upload/newstxt/2010961573965111.doc>通知5</a>
<a href=/upload/newstxt/2010961573965111.doc>通知6</a>
SET @str ='[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知1]'
SELECT replace(replace(@str,'[upload=doc]','<a href='),'[/upload=通知' + left(right(@str,2),1) +']',
LEFT(RIGHT(@str,4),3)+'</a>')----------------------------------------------------------
<a href=/upload/newstxt/2010961573965111.doc通知1</a>(1 row(s) affected)
SET @str ='[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知1][upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知2] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知3] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知4] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知5] [upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知6]'
SELECT replace(replace(replace(@str,'[upload=doc]','<a href='),'[/upload=','>'),']','</a>')
SELECT replace(replace(replace(@str,'[upload=doc]','<a href='),'[/upload=','>'),']','</a>')
--第一步replace(@str,'[upload=doc]','<a href=')
--第二步replace(@str,'[/upload=','>')--因为 ‘通知几’
--第三步replace(@str,']','</a>')
SET @str ='[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知1]'
SELECT replace(replace(@str,'[upload=doc]','<a href='),'[/upload=' + left(right(@str,4),3) +']',
LEFT(RIGHT(@str,4),3)+'</a>')
-----------------------------------------------------
<a href=/upload/newstxt/2010961573965111.doc通知1</a>(1 row(s) affected)
DECLARE @str VARCHAR(1000)
SET @str ='[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=通知1]'
SELECT replace(replace(@str,'[upload=doc]','<a href='),'[/upload=' + left(right(@str,4),3) +']',
'>' + LEFT(RIGHT(@str,4),3)+'</a>')
------------------------------------------------------
<a href=/upload/newstxt/2010961573965111.doc>通知1</a>(1 row(s) affected)
DECLARE @str VARCHAR(1000)
SET @str ='[upload=doc]/upload/newstxt/2010961573965111.doc[/upload=1234324234124]'
SELECT replace(replace(@str,'[upload=doc]','<a href='),'[/upload=' + left(right(@str,4),3) +']',
'>' + LEFT(RIGHT(@str,4),3)+'</a>')