普通EX pression 10位数字,没有任何特殊字符 [英] Regular expression for 10 digit number without any special characters

查看:144
本文介绍了普通EX pression 10位数字,没有任何特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是正恩pression一个10位数字号码(没有特殊字符,没有小数)。

What is the regular expression for a 10 digit numeric number (no special characters and no decimal).

推荐答案

使用这种常规的前pression匹配十位数只有:

Use this regular expression to match ten digits only:

@"^\d{10}$"

要找出连续十位的序列中的任意位置的字符串,请使用:

To find a sequence of ten consecutive digits anywhere in a string, use:

@"\d{10}"

请注意,这也将找到的11位数字的前10位。随时随地搜索的字符串为的完全的连续10个位数,而不是更可以使用负的 lookarounds

Note that this will also find the first 10 digits of an 11 digit number. To search anywhere in the string for exactly 10 consecutive digits and not more you can use negative lookarounds:

@"(?<!\d)\d{10}(?!\d)"

这篇关于普通EX pression 10位数字,没有任何特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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