0
嗨,我试图写一个验证类,使用:regexp-me lib,因为这个post的答案。如何在黑莓({m,n})上使用量词正则表达式模式
我做了什么
String id = "123456789";
String pattern = "\\d{7,8}";
public boolean validate(String id,String pattern){
RE regular_expresion = new RE("\\d{7,8}");
return regular_expresion.match(id);
}
此代码应该返回false与“ID”,因为模式,就像要接受7〜8位数字。但是,如果我使用id =“1234567”它返回true,代码接受7或更多的数字。
{m,n}作为{n,}工作。
有人有过这个问题吗?
哇因此该方法返回真实的,即使它具有具有该模式的子字符串。我不好谢谢你,莫菲。 – AmirG