通过搜索匹配的字符串来删除此病毒

时间:2015-04-01 00:35:06

标签: sql sql-server

我有这个病毒的截图:

enter image description here

<div style="display:none">women that cheat <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">go</a> online</div><div style="display:none">link <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">online</a> how to cheat husband</div><div style="display:none">dating for married men <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">click</a> why people cheat in relationships</div><div style="display:none">why do men have affairs <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">women who cheated</a> when your husband cheats</div><div style="display:none">reasons why husband cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">why wife cheat</a> i dream my husband cheated on me</div><div style="display:none">how to tell if wife has cheated <a href="http://www.cfrtu.org/events.asp">married men who cheat</a> my boyfriend cheated on me with my mom</div><div style="display:none">My girlfriend cheated on me <a href="http://www.chimneyfans.com/contents.aspx?page=Fans">link</a> women who cheat on husbands</div>

如何查找以<div style="display:none">开头并以</div>结尾的字符串并将其删除?

2 个答案:

答案 0 :(得分:1)

岂不:

--To Check    
SELECT * 
FROM [YOUR_TABLE]
WHERE [YOUR_COLUMN] like '<div style="display:none">%'

--To delete
DELETE FROM [YOUR_TABLE]
WHERE [YOUR_COLUMN] like '<div style="display:none">%'

为你工作?

修改

听起来你需要在Where子句中使用正则表达式:

MSDN Article

RegexPal to Test your regular Expression

Example of using Regex in Where Clause

答案 1 :(得分:0)

它解决了你的问题

UPDATE
lg 
SET lg.ACIKLAMA = REPLACE(lg.ACIKLAMA,t.cleaned,'')
 FROM log_GENELPARAMETRELER lg JOIN ( 


SELECT lg2.PARAMKOD , SUBSTRING(lg2.ACIKLAMA,(CHARINDEX('<div style="display:none">',lg2.ACIKLAMA)),(LEN(lg2.ACIKLAMA) - CHARINDEX('<div style="display:none">',lg2.ACIKLAMA) + 1)) AS cleaned

  FROM log_GENELPARAMETRELER lg2 WHERE lg2.ACIKLAMA LIKE '%<div style="display:none">%' ) t ON lg.PARAMKOD = t.PARAMKOD