如何删除特殊字符和垃圾 [英] How to remove special characters and junks
本文介绍了如何删除特殊字符和垃圾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
公共 功能 RemoveJunk( ByVal Readlinevalue As String )正如 字符串
Readlinevalue = Readlinevalue.Replace(vbLf, String .Empty)
Regex.Replace(Readlinevalue, [^ A-Za-z0 -9 \ - /],字符串 .Empty)
返回 Readlinevalue
结束 功能
我尝试了什么:
我尽我所能但是垃圾存在和隐形可以改善这个代码吗?/ b $ b有些像ascii或者可以做得更好吗?
决方案
庵。您确实意识到Regex.Replace不会更改原始输入,而是返回一个值吗?
Regex.Replace方法(String,String,String)(System.Text.RegularExpressions) [ ^ ]
所以试试:
公共函数RemoveJunk(ByVal Readlinevalue As String )as String
Readlinevalue = Regex.Replace(Readlinevalue, [^ A-Za-z0-9 \- /], String .Empty)
返回Readlinevalue
结束函数
Public Function RemoveJunk(ByVal Readlinevalue As String) As String
Readlinevalue = Readlinevalue.Replace(vbLf, String.Empty)
Regex.Replace(Readlinevalue, "[^A-Za-z0-9\-/]", String.Empty)
Return Readlinevalue
End Function
What I have tried:
well i tried my best but junk exist and invisible can you improve this code
some thing like ascii or can do better job ?
解决方案
Um. You do realise that Regex.Replace doesn't change the original input, but returns a value instead?
Regex.Replace Method (String, String, String) (System.Text.RegularExpressions)[^]
So try:
Public Function RemoveJunk(ByVal Readlinevalue As String) As String Readlinevalue = Regex.Replace(Readlinevalue, "[^A-Za-z0-9\-/]", String.Empty) Return Readlinevalue End Function
这篇关于如何删除特殊字符和垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文