自动删除特殊字符 [英] Auto remove special character

查看:73
本文介绍了自动删除特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自动删除将在文本框中显示的特殊字符。来自数据库的数据是这样的 - > 1234-567-89



但是我需要在这样的界面中显示它 - > 123456789。



任何人都可以教我在代码中添加什么,这样我就可以在显示数据时自动删除特殊字符..

解决方案

看一下这个链接



how-remove-all-special-characters-string.html [ ^ ]


这个怎么样:



 。 TextBox1.Text =  Me  .TextBox1.Text.Replace(   -  





- Pete


使用 System.Text.RegularExpressions



请参阅以下代码示例:

  Imports  System.Text.RegularExpressions 

专用 功能 ConvertToCharNumber( ByVal 作为 字符串作为 字符串
尝试
Value = Regex.Replace(Value, [^ \w]
返回
Catc h ex As 异常
返回
结束 尝试
结束 功能



如何使用:

 Messagebox.Show (ConvertToCharNumber(  abcd  -  @#/ blockquote> 

Hi, I need to auto remove special character that will be displayed in the textbox. the data from the database is like this -->1234-567-89

but i need to display it in the interface like this -->123456789.

Can anyone teach me what to add in my code so i can auto remove the special character when the data are displayed..

解决方案

Have a look at this link

how-remove-all-special-characters-string.html[^]


How about this:

Me.TextBox1.Text = Me.TextBox1.Text.Replace("-", "")



- Pete


Use System.Text.RegularExpressions

See the following code Example :

Imports System.Text.RegularExpressions

Private Function ConvertToCharNumber(ByVal Value As String) As String
        Try
            Value = Regex.Replace(Value, "[^\w]", "")
            Return Value
        Catch ex As Exception
            Return Value
        End Try
End Function


How to Use:

Messagebox.Show(ConvertToCharNumber("abcd-@#


这篇关于自动删除特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆