以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]禁止录入*?空格  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=124705)

--  作者:blsu33
--  发布时间:2018/9/12 10:37:00
--  [求助]禁止录入*?空格
老师,
  以前问过禁止录入非法字符的帖子,现在找不到了,用正则怎么写?

--  作者:有点甜
--  发布时间:2018/9/12 10:53:00
--  

textchanged事件,写代码

 

Dim txt As String = e.Sender.Text
If txt > "" Then
    Dim pattern As String = "[*? ]"
    Dim str As String = System.Text.RegularExpressions.Regex.Replace(txt , pattern ,"")
    e.Sender.Text = str
    e.sender.SelectionStart = str.Length
End If