Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 请仅解释此正则表达式=/^[0-9]{3}\d+$/;_Javascript_Regex - Fatal编程技术网

Javascript 请仅解释此正则表达式=/^[0-9]{3}\d+$/;

Javascript 请仅解释此正则表达式=/^[0-9]{3}\d+$/;,javascript,regex,Javascript,Regex,请告诉我这个正则表达式在JavaScript中是什么意思?我对这件事很陌生,也很固执。^=String必须从 var numbonly= /^[0-9]{3}\d+$/; [0-9]=任何数字0-9 {3} =必须有3位数字 \d=[0-9]的任何短数字 +=+是{1,}的缩写。匹配一次或多次 $=字符串结尾 所以在英语中,必须有一个数字[0-9],3次,然后另一个数字[0-9]必须出现1次或更多次。所以基本上这意味着4个或更多的数字。所以可以写得更短,像这样 ^ Matches th

请告诉我这个正则表达式在JavaScript中是什么意思?我对这件事很陌生,也很固执。

^=String必须从

var numbonly= /^[0-9]{3}\d+$/;
[0-9]=任何数字0-9

{3} =必须有3位数字

\d=[0-9]的任何短数字

+=+是{1,}的缩写。匹配一次或多次

$=字符串结尾

所以在英语中,必须有一个数字[0-9],3次,然后另一个数字[0-9]必须出现1次或更多次。所以基本上这意味着4个或更多的数字。所以可以写得更短,像这样

^     Matches the beginning of the String 
[0-9] Matches characters in the range 0-9 
{3}   Matches the previous token [0-9] exactly 3 times 
\d    Matches any digit character
+     Matches previous token \d one or more times 
$     Matches the end of the String

古怪的为什么有人会在同一个正则表达式中使用[0-9]和\d?@user2357112我正要指出same@user2357112'系统应允许X字段中的任意位数;目前的限制是3'我猜这样的要求是给不懂正则表达式的人的,他们从第一个搜索结果中对其进行了编码。你能解释一下为什么我不能在同一个正则表达式中使用[0-9]和\d吗please@user3295255我看你是新来的。如果其中一个答案成功回答了您的问题,请单击该答案旁边的复选标记以接受该问题。谢谢
^\d{4,}$