protected String convertCodeBlock(String input) { Matcher codeFinder = codeblockPattern.matcher(input); String replacement = "{code}{group1}{code}"; String converted = RegexUtil.loopRegex(codeFinder, input, replacement); converted = handleWhitespace(converted); return converted; }
/** 银行帐号为16-21位的数字 */ public static boolean isAccountNumber(TextView w) { if (!RegexUtil.isAccountNumber(w.getText().toString().trim())) { w.setError("银行帐号必须为16-21位的数字!"); w.setFocusable(true); return false; } return true; }
public static boolean isMobileNumber(TextView w) { if (!RegexUtil.isMobileNumber(w.getText().toString().trim())) { w.setError("手机号码为11位数字!"); w.setFocusable(true); return false; } return true; }
public static boolean isArea(TextView w) { if (!RegexUtil.isArea(w.getText().toString().trim())) { w.setError("面积有非法字符!"); w.setFocusable(true); return false; } return true; }
/** * replaces all whitespace seperating the {code} blocks from the content with just one newline. * Example: <br> * if input = <br> * {code} codeblock {code} <br> * <br> * then return = <br> * {code}<br> * codeblock<br> * {code} * * @param input * @return */ protected String handleWhitespace(String input) { Matcher codeNLFinder = codeNLPattern.matcher(input); String replacement = "{group1}\n{group2}\n{group3}"; return RegexUtil.loopRegex(codeNLFinder, input, replacement); }