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.
我允许用户输入我需要确保是有效的 CSS 宽度值的宽度值。
使用正则表达式,我如何从用户输入中获得两个匹配项,其中$matches[0] =一个数字值 AND$matches[1] =要么px要么%?
$matches[0] =
$matches[1] =
px
%
谢谢!
(\d*)(px|%)?
第一个捕获的项目将是数字,第二个捕获的项目将是 px 或 %。