PHP Regexp帮助

Kal*_*nGi 1 php regex

我似乎无法掌握这个表达式打算提取的内容:

preg_match("/^(?:[\s\*]*?@([^\*\/]+?)\s(.+))/",$line,$match);
Run Code Online (Sandbox Code Playgroud)

$ line是文本文件中的一行,而$ match是一个数组

Bar*_*ers 6

这是一个解释:

^               # match the beginning of the input
(?:             # start non-capture group 1 
  [\s*]*?       #   match any character from the set {'0x09'..'0x0D', '0x20', '*'} and repeat it zero or more times, reluctantly
  @             #   match the character '@'
  (             #   start capture group 1
    [^*/]+?     #     match any character from the set {'0x00'..')', '+'..'.', '0'..'ÿ'} and repeat it one or more times, reluctantly
  )             #   end capture group 1
  \s            #   match a whitespace character: [ \t\n\x0B\f\r]
  (             #   start capture group 2
    .+          #     match any character except line breaks and repeat it one or more times
  )             #   end capture group 2
)               # end capture group 1
Run Code Online (Sandbox Code Playgroud)

正则表达式匹配的示例字符串是: * * *@abc asd

编辑:

我发布了用于生成上述解释的解析器的beta版本.它可以在这里下载:http://big-o.nl/apps/pcreparser/pcre/PCREParser.html