开发者

RegExp check if it's a number while it's not empty

I'm using开发者_如何学运维 vbulletin and I can set to custom fields regexp.

I've created a custom field that are userids and only accepts numbers, so the regexp I'm using is:

\d+

But I need to allow it to be empty. Any ideas?

Thanks


\d*

where * indicates 0 or more digits


Then use this:

\d*

This means zero or more digits. Zero digits naturally means it is empty.


Assuming your framework wraps it with the appropriate anchors, just transform that to

\d*

which matches any number of digits, including 0 digits.

/^\d*$/

would be better if nothing is anchoring that for you.


Change this plus (1 or more) to a star (0 or more).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜