java使用正則表達式

String str = "須要匹配的內容";
Pattern patern = Pattern.compile("正則表達式");

Matcher matStart = patern.matcher(str);
Matcher經常使用方法
matcher.matches():是否有匹配
matcher.find():是否找到匹配
matcher.group():返回匹配內容這個能夠和上面的一同使用在while中循環全部匹配內容
matcher.group(int):若是在正則中有分組,使用這個返回分組內容,第一個爲匹配到的內容,index爲1之後的爲分組內容
正​則​表​達​式​部​分​解​釋: http://wenku.baidu.com/view/3556a7697e21af45b307a816.html

版權聲明:本文爲博主原創文章,未經博主容許不得轉載。html

相關文章
相關標籤/搜索