怎么去掉字母? [英] How to remove letters?
问题描述
我只是想问:我有一个 label40.text内容为 {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}我还有一个 label39.text,每次发生某些变化时都会改变它的输出.
i just wanna ask: i have a label40.text with a content of {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} and i also have have a label39.text that will change its output everytime a certain changes happens.
我的问题是我如何通过代码嵌入这个模拟?
My question is How can i embed this simulation through a code?
如果 Label39.text = "a" 则 label40.text "a" 的内容将被删除,字母列表将按字母顺序保留.
If Label39.text = "a" then the content of label40.text "a" will be remove and the list of alphabets will be remain alphabetically.
我希望在我的 label39.text 将随机"更改其值时也会发生这种情况
I want that also to be happen anytime my label39.text will change its value "RANDOMLY"
例如如果 label39.text = "a,b,c,d,x,z" 然后label40.text = "e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"
Example if label39.text = "a,b,c,d,x,z" then label40.text = "e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y"
这是我目前的代码
Dim patterns As String
patterns = Label39.Text
Dim tobefollow As String
tobefollow = Label40.Text
Dim matches As MatchCollection = Regex.Matches(patterns, tobefollow)
If Regex.IsMatch(patterns, tobefollow) Then
'this where i will put my code to make my example
End If
推荐答案
首先,请注意您错误地填充了 patterns
和 tobefollow
变量(您正在做在另一个问题中是正确的);应该是:
First of all, note that you are populating the patterns
and tobefollow
variables wrongly (you were doing it right in the other question); it should be:
patterns = Label40.Text
tobefollow = Label39.Text
还请记住,您可以轻松完成您想要的操作,而无需依赖 Regex
;例如通过:
Also bear in mind that what you want can easily be accomplished without relying on Regex
; for example via:
If (Label40.Text.ToLower().Contains(Label39.Text.ToLower())) Then
'this where i will put my code to make my example
End If
关于这次你想要什么,你可以依靠.Replace
:.Replace("text to be deleted", "")
将删除这个字母;但您还必须考虑逗号.要放入条件中的代码:
Regarding what you want this time, you can rely on .Replace
: .Replace("text to be deleted", "")
will remove this letter; but you have also to account for the commas. Code to be put inside the condition:
Dim origString As String = Label40.Text
Label40.Text = Label40.Text.ToLower().Replace(Label39.Text.ToLower() & ",", "")
If (origString = Label40.Text) Then
'It means that it does not have any comma, that is, refers to the last letter
Label40.Text = Label40.Text.ToLower().Replace("," & Label39.Text.ToLower(), "")
End If
这篇关于怎么去掉字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!