如何去除所有 alpha 的字符串? [英] How to strip a string of all alpha's?
本文介绍了如何去除所有 alpha 的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim phoneNumber As String = "077 47578 587(num)"
我如何从每个不是数字的字符中去除上面的字符串.所以只剩下数字然后检查以确保它是 11 个字符长?
How do i strip the above string off every character which isnt a number. So only the numbers are left and then check to make sure it is 11 characters long?
推荐答案
dim number as string = Regex.Replace(phoneNumber,"[^0-9]","")
if number.length = 11 then
'valid number
else
'not valid
end if
这篇关于如何去除所有 alpha 的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文