정말이 질문에 대한 답변이 확실하지 않습니다.
유효 문자열 목록과 유효하지 않은 문자열 목록을 테스트하고 특정 정규식을 테스트하는 데 사용할 수있는 그루비 스크립트입니다.
def validList = ["9999","[9999]","9-9","[9-9]","09XYAB","ABXY","BA09YX"]
def invalidList = ["[999","9- ", "9-]", "9- 9","9[", "[999[", "09XYABC","1234", "A B"]
def pattern = ~/([09XYAB-]*)|([\[]([09XYAB-]*)([\]]))/
print "Verifying against the regex '${pattern}'\n"
print "Valid List Result(+ve tests)"
print "\n---------------------------------------------\n"
validList.each{
if(pattern.matcher(it).matches()) {
print it +"\ttest passed - Pattern matched\n"
} else {
print it +"\ttest failed - Pattern not matched\n"
}
}
print "\n"
print "inValid List Result(-ve tests)"
print "\n---------------------------------------------\n"
invalidList.each{
if(!(pattern.matcher(it).matches())) {
print it +"\tTest Passed - Pattern not matched\n"
} else {
print it +"\tTest Failed - Pattern matched\n"
}
}
하나는 console
에 테스트 할 수 있습니다
출처
2015-01-17 00:20:35
Rao