工作:在移植一個老系統時,前端頁面需要尋找許多對應的字段。在頁面裏面一個一個排查十分繁瑣。
思考:能否使用一個腳本去將所需要的的html標籤從冗雜的老頁面中提取出來。
使用正則表達式去匹配html標籤,匹配篩選出需要的內容
public static void main(String[] args) {
String html = "****";
String rgex = "<label.*>";
Pattern p = Pattern.compile(rgex);
Matcher m = p.matcher(html);
while (m.find()) {
System.out.println(m.group());
}
}
結果
這樣在篩選出的結果裏面查找是不是方便許多。