仅用于数字的正则表达式 [英] Regex for just only numbers

查看:52
本文介绍了仅用于数字的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用太多正则表达式,所以我有困难.我想要只验证该字段包含数字的正则表达式,但不关心有多少.

I haven't used regular expressions soo much, so I'm having difficulty . I want regex that only validates that the field contains digits, but that does not care about how many.

它应该批准77和2377?但不批准 77.43 或 xyz777.

It should approve 77 and 2377? But do not approve 77.43 or xyz777.

我怎样才能使用正则表达式得到这个?这个表达式 ^[0-9]+$ ok or not

How can I get this using regular expression? Is this expression ^[0-9]+$ ok or not

推荐答案

没关系.无论如何,您只需使用 ^\d+$ 即可.

It's OK. You can just use ^\d+$ for all it matters anyway.

这篇关于仅用于数字的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆