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.
我正在使用 vbulletin,我可以设置自定义字段正则表达式。
我创建了一个自定义字段,它是用户 ID,只接受数字,所以我使用的正则表达式是:
\d+
但我需要让它为空。有任何想法吗?
谢谢
假设您的框架用适当的锚点包装它,只需将其转换为
\d*
匹配任意位数,包括 0 位数。
/^\d*$/
如果没有什么可以为您锚定它会更好。
其中 * 表示 0 个或多个数字
然后使用这个:
这意味着零个或多个数字。零位自然意味着它是空的。
将此加号(1 或更多)更改为星号(0 或更多)。