普通EX pression 10位数字,没有任何特殊字符没有任何、特殊字符、普通、数字

2023-09-02 21:54:50 作者:山谷

什么是正恩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)"