我想检查一个字符串是否符合特定的模式。
例如我想检查一个字符串是否匹配模式:2012-02-20。
I.E: xxxx-xx-xx 当 x 是一个数字时。
这可能吗?有人说正则表达式。
最佳答案
使用这个正则表达式 \d{4}-\d{2}-\d{2}
检查使用:
yourString.matches(regexString);
关于java - 检查特定模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14727090/