日期:2014-05-16 浏览次数:20482 次
public class PatternTest { private final static String TN_NAME_SUFFIX_REGEX = "[a-zA-Z0-9]+$"; private final static Pattern TN_NAME_SUFFIX_PATTERN = Pattern.compile(TN_NAME_SUFFIX_REGEX); @Test public void testPattern(){ Assert.assertTrue(!TN_NAME_SUFFIX_PATTERN.matcher("aaB%").matches()); Assert.assertTrue(!TN_NAME_SUFFIX_PATTERN.matcher("aaB_").matches()); Assert.assertTrue(TN_NAME_SUFFIX_PATTERN.matcher("aaB0").matches()); } }
var v = $.trim(formMap.tnNameSuffix); var pattern = /[0-9a-zA-Z]+$/g; if (!v || v.length == 0) { return "[自定义标识]请填写自定义标识!"; } else if (v.length > 16) { return "[自定义标识]过长,最多填写16位!"; } else if(!pattern.test(v)){ return "[自定义标识]不合法,只能为[0-9a-zA-Z],请检查!"; }
var v = $.trim(formMap.tnNameSuffix); var pattern = /^[0-9a-zA-Z]+$/g; if (!v || v.length == 0) { return "[自定义标识]请填写自定义标识!"; } else if (v.length > 16) { return "[自定义标识]过长,最多填写16位!"; } else if(!pattern.test(v)){ return "[自定义标识]不合法,只能为[0-9a-zA-Z],请检查!"; }