Java realizes the regular expression judgment date

xiaoxiao2021-03-06  72

Import org.apache.oro.text.regex.patternmatcher;

Import Org.Apache.oro.text.Regex.perl5matcher;

Import org.apache.oro.text.regex.patterncompiler;

Import Org.Apache.oro.text.Regex.perl5compiler;

Import Org.Apache.oro.text.Regex.pattern;

Public static boolean isvalidagesegment (string agesegment) {

String s = "[0-9] {2} [# ] [0-9] {2}";

Patternmatcher matcher = new perl5matcher ();

PatternCompiler Compiler = new perl5compiler ();

Try {

Pattern Pattern = compiler.compile (s);

Return matcher.matches (agsegment, pattern);

}

Catch (MalformedPatterNexception EX) {

Log.Error (ex);

Return False;

}

}

转载请注明原文地址:https://www.9cbs.com/read-93382.html

New Post(0)