如何在将文字包含在第一组后不在正则表达式中包含文字?

How to not include in regex a literal after including it in the first group?

我正在使用 preg_match_all() 来匹配一些字符串。

这是我的代码

preg_match_all('@([a-zA-Z0-9,\(\)\-\s\.\#:]*)Date From: [0-9]{2}/[0-9]{2}/[0-9]{4}([, \s]*[0-9]{2}/[0-9]{2}/[0-9]{4})*\s(Division Type: [A-Z ]*)*@m', $string, $match);

这是输出

https://regex101.com/r/hE3iO2/1

现在,我想将 / 添加到第一组以在捕获组中包含文字 /,这发生了

来自这个

([a-zA-Z0-9,\(\)\-\s\.\#:]*)

到这个

([a-zA-Z0-9,\(\)\-\s\.\#:/]*)

https://regex101.com/r/wM1rW7/1

/ 添加到群组时如何防止这种情况发生?

让你的正则表达式非贪婪:

([a-zA-Z0-9,()\s.#:/-]*?)Date From: [0-9]{2}/[0-9]{2}/[0-9]{4}([, \s]*[0-9]{2}/[0-9]{2}/[0-9]{4})*\s(Division Type: [A-Z ]*)*

RegEx Demo