Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
匹配正则表达式/^(?:\.(\d{3}))*$/s会.234.567产生以下输出:
/^(?:\.(\d{3}))*$/s
.234.567
array (size=2) 0 => array (size=1) 0 => string '.234.567' (length=8) 1 => array (size=1) 0 => string '567' (length=3)
为什么234没有列在第二个子数组中?
234
由于@develroot 已经回答了您想要使用 preg_match_all 的方式不起作用,它只会返回最后一个匹配组,而不是该组的所有捕获。这就是正则表达式的工作原理。
(https://stackoverflow.com/a/6635830/1515333)