我正在尝试使用Visual Basic替换字符串中的整数,但似乎无法正确处理。
这是我目前拥有的:
lblNewPassword.Text = txtOrigPassword.Text.Replace("[0-9]", "Z")
我也尝试过:
lblNewPassword.Text = txtOrigPassword.Text.Replace("#", "Z")
和:
lblNewPassword.Text = txtOrigPassword.Text.Replace("*#*", "Z")
你必须使用这样的正则表达式对象:
C#
string input = "This is t3xt with n4mb3rs.";
Regex rgx = new Regex("[0-9]");
string result = rgx.Replace(input, "Z");
.VB
Dim input As String = "This is t3xt with n4mb3rs."
Dim rgx As New Regex("[0-9]")
Dim result As String = rgx.Replace(input, "Z")
更新:如果您想更改元音X
您可以添加:
rgx As New Regex("[A-Za-z]")
result = rgx.Replace(result, "X")