Foxtable(狐表)用户栏目专家坐堂 → [求助]替换剪贴板内容


  共有1871人关注过本帖树形打印复制链接

主题:[求助]替换剪贴板内容

帅哥哟,离线,有人找我吗?
天一生水
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1140 积分:11255 威望:0 精华:0 注册:2017/9/26 16:30:00
[求助]替换剪贴板内容  发帖心情 Post By:2018/7/6 8:05:00 [显示全部帖子]

窗口粘贴网页内容时,希望将除段落<p>以外的标签都过滤掉。

请老师帮助解决:

1、下面加黑的过滤标签代码,怎样修改;

2、代码放在哪里?

谢谢!

 

If ClipBoard.ContainsText Then     '剪贴板替换
   Dim s As String = ClipBoard.GetText()
   Dim strText As String = System.Text.RegularExpressions.Regex.Replace(s, "<br>|<BR>|<br/>|<BR/>", chr(11))
   strText = System.Text.RegularExpressions.Regex.Replace(strText, "<[^>]+?>", "")
   strText = System.Text.RegularExpressions.Regex.Replace(strText, chr(11), "<br/>")

   s = strText
   'Return strText            
End If

 


 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1140 积分:11255 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2018/7/6 11:52:00 [显示全部帖子]

老师,我放到窗口或窗口相应编辑控件的keydown事件里,运行没反应,也没有弹出窗口,是什么原因?

 

If e.keycode = keys.v andalso e.control = true Then

Dim s As String = ClipBoard.GetText()
Dim strText As String = System.Text.RegularExpressions.Regex.Replace(s, "<br>|<BR>|<br/>|<BR/>", chr(11))
strText = System.Text.RegularExpressions.Regex.Replace(strText, "<p>|<P>", chr(254))
strText = System.Text.RegularExpressions.Regex.Replace(strText, "</p>|</P>", chr(255))
strText = System.Text.RegularExpressions.Regex.Replace(strText, "<[^>]+?>", "")
strText = System.Text.RegularExpressions.Regex.Replace(strText, chr(11), "<br/>")
strText = System.Text.RegularExpressions.Regex.Replace(strText, chr(254), "<p>")
strText = System.Text.RegularExpressions.Regex.Replace(strText, chr(255), "</p>")
msgbox(strText)

s = strText

End if


 回到顶部