vb.net 查找出现的点号 dot

vb.net find occurrences of dot number dot

对于那些擅长正则表达式等的人来说,这应该是一个真正快速的方法,我有一些字符串,我只想提取那些有一个点然后是 0-9 之间的单个数字最后是另一个点的字符串。因此:

string2.string = no good

string.1.string = match

strstr.9.strstr = match

str3.-3.str = no good

试试这个:

\.\d\.

演示:https://regex101.com/r/zC3iQ9/1

和 VB 代码:

Dim input = "string.1.string"
Dim pattern = "\.\d\."
Dim matches = Regex.Match(input, pattern).Success

你不需要正则表达式,在 VB.NET 你有简单的 Like-operator:

Dim matches = From str In strings
              Where str Like "*.#.*"
Console.WriteLine(String.Join(Environment.NewLine, matches))