Php vb.net regex.matches未返回所有匹配项

Php vb.net regex.matches未返回所有匹配项,php,regex,vb.net,preg-match-all,Php,Regex,Vb.net,Preg Match All,仅返回: 在位置0处找到“9#Left#Itema Desc” 使用Expresso返回测试上面的vb模式: 1:9 2:#左# 3:项目A 4:Desc 此外,此PHP正则表达式还返回四项: Dim pattern As String = "^[ \t]*(\d+)[ \t]*(#[^#]*#)?[ \t]*(\w+)[ \t]?(.*)$" Dim sentence As String = "9 #Left# Itema Desc" For Each match As Match In R

仅返回:

在位置0处找到“9#Left#Itema Desc”

使用Expresso返回测试上面的vb模式:

1:9

2:#左#

3:项目A

4:Desc

此外,此PHP正则表达式还返回四项:

Dim pattern As String = "^[ \t]*(\d+)[ \t]*(#[^#]*#)?[ \t]*(\w+)[ \t]?(.*)$"
Dim sentence As String = "9 #Left# Itema Desc"

For Each match As Match In Regex.Matches(sentence, pattern)
  Console.WriteLine("Found '{0}' at position {1}", match.Value, match.Index)
Next
我做错了什么

提前谢谢

多亏了Ark kun,我的问题确实是群体——以下是有效的代码:

preg_match_all('/^[ \t]*(\d+)[ \t]*(#[^#]*#)?[ \t]*(\w+)[ \t]?(.*)$/m', $in, $matches, PREG_SET_ORDER);

结果在逻辑上是正确的。您已经编写了“整行”正则表达式,并且
regex.Matches
方法找到了一个匹配项-整行。 您可能需要的是
匹配。捕获
属性:

Dim pattern As String = "^[ \t]*(\d+)[ \t]*(#[^#]*#)?[ \t]*(\w+)[ \t]?(.*)$"
Dim sentence As String = "9 #Left# Itema Desc"

Dim match As Match = Regex.Match(sentence, pattern)
If match.Success Then
  Console.WriteLine("Matched text: {0}", match.Value)
    For ctr As Integer = 1 To match.Groups.Count - 1
      Console.WriteLine("   Group {0}:  {1}", ctr, match.Groups(ctr).Value)
    Next
 End If