Validation of Java characters

Source: Internet
Author: User

Package Net.hlj.common.util;import java.util.regex.matcher;import java.util.regex.pattern;/** * @ project Name: HouseInfo * @ Package Name: Net.hlj.common.util * @ file name: Datavalidator.java * @ Date: Feb, 3:32:01 PM * @ Note: Data validation class * @apple */public class Dataval Idator {/** * is an integer * @param value */public static Boolean Isintege (String value) {Pattern p=null;//regular expression Matcher m=null;// The character expression Boolean b=false;p=p.compile ("^-?[ 1-9]\\d*$ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a positive integer * @param value */public static Boolean isIntege1 (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression b Oolean b=false;p=p.compile ("^[1-9]\\d*$"); M=p.matcher (value); b=m.matches (); return b;} /** * is a negative integer * @param value */public static Boolean isIntege2 (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression b Oolean b=false;p=p.compile ("^-[1-9]\\d*$"); M=p.matcher (value); b=m.matches (); return b;} /** * is a number * @param value */public static Boolean isnum (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boolea N b=false;p=P.compile ("^ ([+ +]?) \\d*\\.? \\d+$ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a positive number (positive integer + 0) * @param value */public static Boolean isNum1 (String value) {Pattern p=null;//regular expression Matcher m=null;//operation Character Expression Boolean b=false;p=p.compile ("^[1-9]\\d*|0$"); M=p.matcher (value); b=m.matches (); return b;} /** * is negative (negative integer + 0) * @param value */public static Boolean isNum2 (String value) {Pattern p=null;//regular expression Matcher m=null;//operation Character Expression Boolean b=false;p=p.compile ("^-[1-9]\\d*|0$"); M=p.matcher (value); b=m.matches (); return b;} /** * is a floating-point number * @param value */public static Boolean isdecmal (String value) {Pattern p=null;//regular expression matcher m=null;//operator-expression bo Olean B=false;p=p.compile ("^ ([+ +]?) \\d*\\.\\d+$ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a positive floating-point number * @param value */public static Boolean IsDecmal1 (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boolean B=false;p=p.compile ("^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$"); M=p.matcher (value); b=m.matches (); return b;} /** * is a negative floating-point number * @param value */public static boolEan IsDecmal2 (String value) {Pattern p=null;//regular expression Matcher m=null;//operator expression Boolean b=false;p=p.compile ("^-([1-9]\\d*]. \\d*|0.\\d*[1-9]\\d*) $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a floating-point number * @param value */public static Boolean IsDecmal3 (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression b Oolean b=false;p=p.compile ("^-?" ( [1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?. 0+|0) $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a non-negative floating point number (positive floating point + 0) * @param value */public static Boolean IsDecmal4 (String value) {Pattern p=null;//regular expression Matcher m=nu ll;//operator Expression Boolean b=false;p=p.compile ("^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?. 0+|0$ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a non-positive floating point number (negative floating point + 0) * @param value */public static Boolean ISDECMAL5 (String value) {Pattern p=null;//regular expression Matcher m=nu ll;//operator Expression Boolean b=false;p=p.compile ("^ (-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)] | 0+|0$ "); M=p.matcher (value); b=m.matches (); return b;} /** * is the message * @param value */public static Boolean Isemail (String value) {PatTern p=null;//Regular expression Matcher m=null;//operator expression Boolean b=false;p=p.compile ("^\\w+ ((-\\w+) | ( \\.\\w+)) *\\@[a-za-z0-9]+ ((\\.| -) [a-za-z0-9]+] *\\. [a-za-z0-9]+$]; M=p.matcher (value); b=m.matches (); return b;} /** * is color * @param value */public static Boolean IsColor (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bool Ean B=false;p=p.compile ("^[a-fa-f0-9]{6}$"); M=p.matcher (value); b=m.matches (); return b;} /** * is URL * @param value */public static Boolean Isurl (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boole An B=false;p=p.compile ("^http[s]?:\ \/\\/([\\w-]+\\.) +[\\w-]+ ([\\w-./?%&=]*)? $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is Chinese * @param value */public static Boolean Ischinese (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bo Olean b=false;p=p.compile ("^[\\u4e00-\\u9fa5\\uf900-\\ufa2d]+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the acsii character * @param value */public static Boolean isascii (String value) {Pattern p=null;//regular expression Matcher m=null;//The operator expression Boolean b=false;p=p.compile ("^[\\x00-\\xff]+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is zip code * @param value */public static Boolean Iszipcode (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bo Olean b=false;p=p.compile ("^\\d{6}$"); M=p.matcher (value); b=m.matches (); return b;} /** * is cell phone * @param value */public static Boolean ismobile (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boo Lean B=false;p=p.compile ("^ (13|15) [0-9]{9}$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the IP address * @param value */public static Boolean isIp (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boole An B=false;p=p.compile ("^ (25[0-5]|2[0-4]\\d|[ 0-1]\\d{2}| [1-9]?\\d] \ \. (25[0-5]|2[0-4]\\d| [0-1]\\d{2}| [1-9]?\\d] \ \. (25[0-5]|2[0-4]\\d| [0-1]\\d{2}| [1-9]?\\d] \ \. (25[0-5]|2[0-4]\\d| [0-1]\\d{2}| [1-9]?\\d) $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is non-null * @param value */public static Boolean Isnotempty (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bOolean b=false;p=p.compile ("^\\s+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the picture * @param value */public static Boolean ispicture (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bo Olean B=false;p=p.compile ("(. *) \ \." ( JPG|BMP|GIF|ICO|PCX|JPEG|TIF|PNG|RAW|TGA) $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is a compressed file * @param value */public static Boolean Israr (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bool Ean B=false;p=p.compile ("(. *) \ \." ( RAR|ZIP|7ZIP|TGZ) $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is the date * @param value */public static Boolean isDate (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boole An B=false;p=p.compile ("^ ((\\d{2} ([02468][048]) | ( [13579] [26])) [\\-\\/\\s]? (((0? [13578]) | (1[02])) [\\-\\/\\s]? ((0? [1-9]) | ([1-2][0-9]) | (3[01])) | ((0? [469]) | (11)) [\\-\\/\\s]? ((0? [1-9]) | ([1-2][0-9]) | (30))) | (0?2[\\-\\/\\s]? ((0? [1-9]) | ([1-2][0-9])))) | (\\d{2} ([02468][1235679]) | ( [13579] [01345789])) [\\-\\/\\s]? (((0? [13578]) | (1[02])) [\\-\\/\\s]? ((0? [1-9]) | ([1-2][0-9]) | (3[01])) | ((0? [469]) | (11)) [\\-\\/\\s]? ((0? [1-9]) | ([1-2][0-9]) | (30))) | (0?2[\\-\\/\\s]? ((0? [1-9]) | (1[0-9]) | (2[0-8]))))) (\\s ((0?[ 0-9]) | ([1-2][0-3])) \ \:([0-5]? [0-9]) ((\\s) | (\ \:([0-5]? [0-9])))? $ "); M=p.matcher (value); b=m.matches (); return b;} /** * is QQ number * @param value */public static Boolean isqq (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Boole An b=false;p=p.compile ("^[1-9]*[1-9][0-9]*$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the function of the phone number (including verifying the domestic area code, international area code, extension number) * @param value */public static Boolean Istel (String value) {Pattern p=null;//regular expression MATC Her m=null;//operator expression, Boolean b=false;p=p.compile ("^ ([0\\+]\\d{2,3}-)?" ( 0\\d{2,3})? (\\d{7,8}) (-(\\d{3,}))? $ "); M=p.matcher (value); b=m.matches (); return b;} /** * for user registration. Matches a string consisting of a number, 26 letters, or an underscore * @param value */public static Boolean Isusername (String value) {Pattern p=null;//regular expression Matcher m =null;//operator Expression Boolean b=false;p=p.compile ("^\\w+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the letter * @pAram value */public static Boolean Isletter (String value) {Pattern p=null;//regular expression matcher m=null;//operator-expression Boolean b=false; P=p.compile ("^[a-za-z]+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is capital letter * @param value */public static Boolean Isletter_u (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Type Boolean b=false;p=p.compile ("^[a-z]+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is capital letter * @param value */public static Boolean isletter_l (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression Type Boolean b=false;p=p.compile ("^[a-z]+$"); M=p.matcher (value); b=m.matches (); return b;} /** * is the price * @param value */public static Boolean Isprice (String value) {Pattern p=null;//regular expression matcher m=null;//operator expression bool Ean B=false;p=p.compile ("^ ([1-9]{1}[0-9]{0,} (\\.[ 0-9]{0,2})? | 0 (\\.[ 0-9]{0,2})? | \\. [0-9] {.}) $ "); M=p.matcher (value); b=m.matches (); return b;} public static void Main (string[] args) {Boolean b=isprice ("25.67"); System.out.println (b);}}

Transferred from: http://dpn525.iteye.com/blog/1420216

Validation of Java characters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.