“将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。 ”
比如这句话 中文 我不要,我只要xsda ,QKDY4 还有就是 KS1 三个出来中文以外的英文字母提取出来 ,分别 用三个变量装着
应该怎么写代码呀?
7 个解决方案
#1
表达不清楚,不知道你要实现什么功能
#2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mc As MatchCollection = Regex.Matches("将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。", "[^\u4E00-\u9FA5\W]+")
For Each m As Match In mc
MessageBox.Show(m.Value)
Next
End Sub
#3
Sub Main()
Dim mc As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches("将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。", "[^\u4E00-\u9FA5\W]+")
Dim i As Integer = mc.Count
Dim Arr(i) As String '变量个数不确定用数组定义
For Each m As Text.RegularExpressions.Match In mc
Arr(i) = m.Value '赋值给数组
Console.WriteLine(m.Value.ToString)
Next
Console.ReadLine()
End Sub
#4
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。"
Dim mhs As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(s, "[A-Z,a-z,0-9]+")
For Each mh As System.Text.RegularExpressions.Match In mhs
Debug.Print(mh.Value) '在即时窗口看输出
Next
End Sub
End Class
#5
一句话,正则来得简单,不过这个很流行的正则表达式,好像……稍稍有一点点问题!换个思路,用/w或 [0-9a-zA-Z]怎么样。
#6
问题已经解决了 谢谢大家 ~
#7
学习了!
#1
表达不清楚,不知道你要实现什么功能
#2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mc As MatchCollection = Regex.Matches("将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。", "[^\u4E00-\u9FA5\W]+")
For Each m As Match In mc
MessageBox.Show(m.Value)
Next
End Sub
#3
Sub Main()
Dim mc As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches("将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。", "[^\u4E00-\u9FA5\W]+")
Dim i As Integer = mc.Count
Dim Arr(i) As String '变量个数不确定用数组定义
For Each m As Text.RegularExpressions.Match In mc
Arr(i) = m.Value '赋值给数组
Console.WriteLine(m.Value.ToString)
Next
Console.ReadLine()
End Sub
#4
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "将考生文件夹下的表xsda和QKDY4加入到新建的数据库KS1中。"
Dim mhs As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(s, "[A-Z,a-z,0-9]+")
For Each mh As System.Text.RegularExpressions.Match In mhs
Debug.Print(mh.Value) '在即时窗口看输出
Next
End Sub
End Class
#5
一句话,正则来得简单,不过这个很流行的正则表达式,好像……稍稍有一点点问题!换个思路,用/w或 [0-9a-zA-Z]怎么样。
#6
问题已经解决了 谢谢大家 ~
#7
学习了!