이 기사에서는 참조를 위해 특정 Java 정규 표현 도구의 특정 코드를 공유했습니다. 특정 내용은 다음과 같습니다
import com.google.common.base.strings; import java.util.regex.matcher; import java.util.regex.pattern;/*** 일반적으로 사용되는 일반 표현식* 2016/4/7에 Tookbra가 만든 일반적인 표현식*. */public class regexutils {/** * 그것이 올바른 IP 주소 여부를 결정 * * @param ip * @return boolean true, pass, false, 실패 */public static boolean isip (string ip) {if (strings.isnullorempty (ip)) retud false; String regex = "^(1 // d {2} | 2 [0-4] // d | 25 [0-5] | [1-9] // d | [1-9]) //." + "(1 // d {2} | 2 [0-4] // d | 25 [0-5] | [1-9] // d | // d) //." + "(1 // d {2} | 2 [0-4] // d | 25 [0-5] | [1-9] // d |/d) //." + "(1 // d {2} | 2 [0-4] // d | 25 [0-5] | [1-9] // d | // d) $"; 반환 ip.matches (Regex); } / ** * 올바른 이메일 주소 여부를 결정하십시오 * @param email * @return boolean true, passed, false, 실패 * / public static boolean iseMail (string email) {if (strings.isnullorEmpty (이메일)) false retud false; String regex = "//wlfle(4-+. ]//w+)*@/wle(...- ]//w+)*//wlo (/-..-. ]//w+)*"; 반환 이메일 .matches (Regex); } / ** * 중국어가 포함되어 있는지, 구두점을 포함하지 않고 중국어에만 적합한 지 결정 * @param text * @return boolean true, passed, false, 실패 * / public static boolean ischinese (문자열 텍스트) {if (strings.isnullorempty (text)) 거짓; 패턴 p = pattern.compile ( "[/u4e00-/u9fa5]"); 매치 자 m = p.matcher (텍스트); return m.find (); } / ** * 긍정적 인 정수 * * @param 번호 * 번호 * @return boolean true, pass, false, 실패 * / public static boolean isnumber (문자열 번호) {if (strings.isnullorEmpty (number)) false를 반환합니다. String regex = "[0-9]*"; 반환 번호 .matches (Regex); } / ** * 얼마나 많은 소수의 소수 (양수) * * @param decimal * 번호 * @param count * decimal digits * @return boolean true, pass, false, 실패 * / public static boolean isdecimal (string decimal, int count) {if (strings.isnullorempty (decimal)) return false; String regex = "^(-)? (([1-9] {1} // d*) | ([0] {1})) (// d) {" + count + "})? $"; 소수점을 반환합니다. } / ** * 휴대 전화 번호 여부를 결정하십시오 * * @param phoneNumbe * 휴대 전화 번호 * @return boolean true, pass, false, 실패 * / public static boolean ismobilephonenumber (string phoneNumber) {if (strings.isnullorempty (phoneNumber)) 거짓; String regex = "^((13 [0-9]) | (15 [0-9]) | (18 [1-9]) // d {8} $"; return phoneNumber.matches (Regex); } / ** * 휴대 전화 번호 여부를 결정하십시오 * @param phoneMber * 휴대 전화 번호 * @return boolean true, pass, false, 실패 * / public static boolean isphoneNumber (String phoneNumber) {if (strings.isnullorEmpty (phoneNumber)) 거짓; String regex = "^1 // d {10} $"; return phoneNumber.matches (Regex); } / ** * 특수 문자가 포함되어 있는지 여부를 결정하십시오 * @param text * @return boolean true, pass, false, faild * / public static boolean hasspecialchar (string text) {if (strings.isnullorEmpty (text)) false를 반환합니다. if (text.replaceall ( "[az]*[az]]*// d*-*_*// s*", "") .length () == 0) {// 특수 문자가 포함되지 않은 경우 true를 반환합니다. } false를 반환합니다. } private static boolean ischinese (char c) {ar if (ub == arribute.unicodeblock.cjk_unified_ideographs || ub == arribute.unicodeblock.cjk_compatibility_ideographs || ub == arribute.unicodeblock.cjk_unife_ideographs_extension_a || ub == cataRy.unicodeBlock.cjk_unifaphing_ideafographs_ideafographs_ideafographs_ideafographs. char } false를 반환합니다. }}위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.