Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.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
Java正则表达式(4位数字后跟2个零)_Java_Regex - Fatal编程技术网

Java正则表达式(4位数字后跟2个零)

Java正则表达式(4位数字后跟2个零),java,regex,Java,Regex,这个很简单 编写一个java程序,其中用户输入4位数字,后跟2个零。 中间没有空隙 例:123400454500988900 这是我的代码: String password = in.nextLine(); Pattern Pass = Pattern.compile("^[0-9]{4}.[0]{2}.$"); Matcher matPASS = Pass.matcher(password); 它正在检查表达式是否正确。我该如何重写中的表达式?谢谢JBone,删除两个点确实可以匹配

这个很简单

编写一个java程序,其中用户输入4位数字,后跟2个零。 中间没有空隙

例:123400454500988900

这是我的代码:

String password = in.nextLine();    

Pattern Pass = Pattern.compile("^[0-9]{4}.[0]{2}.$");
Matcher matPASS = Pass.matcher(password);

它正在检查表达式是否正确。我该如何重写中的表达式?

谢谢JBone,删除两个点确实可以匹配

Pattern Pass = Pattern.compile("^[0-9]{4}[0]{2}$");

我否决了这个问题,因为它是一个零努力的需求转储。如果您可以通过提问向我们展示您的尝试,或者明确您遇到困难的地方,则此否决票可能会被撤回。如果您停止尝试并提出具体问题的原因很简单,我刚刚发布了有问题的代码。回答很好,因为无论我做什么,eclipse似乎没有识别出4位数字和2位零,这两个点都是。从你的表情。