标签:
正则表达式:是指一个用来描述或者匹配一系列符合某个语法规则的字符串的单个字符串。其实就是一种规则
* A:字符类
* [abc] a、b 或 c(简单类)
* [^abc] 任何字符,除了 a、b 或 c(否定)
* [a-zA-Z] a到 z 或 A到 Z,两头的字母包括在内(范围)
* [0-9] 0到9的字符都包括
* B:预定义字符类
* . 任何字符。
* \d 数字:[0-9]
* \w 单词字符:[a-zA-Z_0-9]
* C:Greedy 数量词
* X? X,一次或一次也没有
* X* X,零次或多次
* X+ X,一次或多次
* X{n} X,恰好 n 次
* X{n,} X,至少 n 次
* X{n,m} X,至少 n 次,但是不超过 m 次
正则表达式的分个功能:public String[] split(String regex)
正则表达式的替换功能:public String replaceAll(String regex,String replacement)
正则表达式的分组功能:捕获组可以通过从左到右计算其开括号来编号
Pattern和Matcher的调用顺序:
* Pattern p = Pattern.compile("a*b");
* Matcher m = p.matcher("aaaaab");
* boolean b = m.matches();
正则表达式的获取功能:
String s = "我的手机是18988888888,我曾用过18987654321,还用过18812345678";
String regex = "1[3578]\\d{9}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(s);
while(m.find()) //获取一次后该相当于指针指向,下次再找会到后续字符串找
System.out.println(m.group());
Math类:
* public static int abs(int a)
* public static double ceil(double a)
* public static double floor(double a)
* public static int max(int a,int b) min自学
* public static double pow(double a,double b)
* public static double random()
* public static int round(float a) 参数为double的自学
* public static double sqrt(double a)
Random类:
public int nextInt(int n)(重点掌握)//n值为需要生成的0-n的int值 包含0 不包含100
System类:
* public static void gc()
* public static void exit(int status)
* public static long currentTimeMillis()
* pubiic static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
BigInteger和BigDecimal:
* public BigInteger add(BigInteger val)
* public BigInteger subtract(BigInteger val)
* public BigInteger multiply(BigInteger val)
* public BigInteger divide(BigInteger val)
* public BigInteger[] divideAndRemainder(BigInteger val)
Date类:表示特定的瞬间,精确到毫秒
* public long getTime()
* public void setTime(long time)
SimpleDateFormat类:日期/时间格式化子类的抽象类,它以与语言无关的方式格式化并解析日期或时间
Calendar类:是一个抽象类,它为特定瞬间与一组诸如 YEAR、MONTH、DAY_OF_MONTH、HOUR 等日历字段之间的转换提供了一些方法,并为操作日历字段(例如获得下星期的日期)提供了一些方法
* public static Calendar getInstance()
* public int get(int field)
* public void add(int field,int amount)
* public final void set(int year,int month,int date)
标签:
原文地址:http://www.cnblogs.com/meng726477179/p/5770942.html