[番外]:帶你玩正則1--資料遍地是,看你取不取

張風捷特烈發表於2018-12-07

謹言:正則沒有捷徑,唯一法可破,多想,多用,再多想,再多用

最近想做個Android資源庫:toly_res開源庫,將一些常用字串和res資源收錄進去
所以找些字串練練手,做個資源儲備,順便磨一下我正則這把鏽跡斑斑的刀
正則的基礎知識我就不羅嗦了,一些常用符號不懂的可以自己查一查。
本文將用四個小例子介紹正則的使用


1.一百單八將的獲取

隨便從網上拷貝一份一百零八將的字串,怎麼把他優化到可用程度?

src.png

1.1:去除形如3.37.1的字元

行尾點保留,將作為分割的標示。正則式:"(\\d+\\.)(\\d{0,2}\\.?": 仔細分析一下,想要匹配到的東西:

情況1:---------------------:2.
情況2:---------------------:10.
情況3:---------------------:37.1
情況4:---------------------:44.8.
情況5:---------------------:46.10.

(\\d+\\.)----------說明匹配一個或多個數字,並且後面有點:情況1、情況2 get
(\\d{0,2}\\.?) ----說明匹配零到2個數字,並且後面有一個點或沒有點 情況3、情況4、情況5 get

效果就是選中了五種情況,看下效果:
String dest = str.replaceAll("(\\d+\\.)(\\d{0,2}\\.?)","");
複製程式碼

效果.png

可見清爽了許多,然後用點.或者:進行切分:


1.2:切割每個人

切割過後資料就規整許多了

String[] strings = dest.split("\\.|:");
for (String string : strings) {
    if (string.contains("…")) {//過濾雜物
        System.out.println(string);
    }
}
複製程式碼

效果2.png


1.3:建立實體類承接資料
public class Hero {
    private String star;
    private String nickName;
    private String name;
    //get---set---toString略...
}
複製程式碼
String[] strings = dest.split("\\.|:");
for (String string : strings) {
    if (string.contains("…")) {//過濾雜物
        string= string.replaceAll("\\s", "");
        String[] split = string.split("…");
        heroes.add(new Hero(split[0], split[1], split[2]));
    }
}
System.out.println(heroes);
複製程式碼

好了,現在物件的列表都在手上,還不隨意擺弄嗎?

效果3.png


1.4為了方便使用,生成Json字串

implementation 'com.google.code.gson:gson:2.8.5'

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setPrettyPrinting();//美化輸出的json格式化
String json = gsonBuilder.create().toJson(heroes);
複製程式碼

Json.png

從網上拷貝的介紹文到實體化,再轉為json字串,只用了這點程式碼,如果靠手動擋,估計要敲的夠嗆。
對於一些有規律而複雜的字串,優先考慮邏輯生成。才能以一敵百,解放雙手。
此字串已收錄:toly_res開源庫

[
  {
    "star": "天魁星",
    "nickName": "呼保義",
    "name": "宋江"
  },
  {
    "star": "天罡星",
    "nickName": "玉麒麟",
    "name": "盧俊義"
  },
  {
    "star": "天機星",
    "nickName": "智多星",
    "name": "吳用"
  },
  {
    "star": "天閒星",
    "nickName": "入雲龍",
    "name": "公孫勝"
  },
  {
    "star": "天勇星",
    "nickName": "大刀",
    "name": "關勝"
  },
  {
    "star": "天雄星",
    "nickName": "豹子頭",
    "name": "林沖"
  },
  {
    "star": "天猛星",
    "nickName": "霹靂火",
    "name": "秦明"
  },
  {
    "star": "天威星",
    "nickName": "雙鞭",
    "name": "呼延灼"
  },
  {
    "star": "天英星",
    "nickName": "小李廣",
    "name": "花榮"
  },
  {
    "star": "天貴星",
    "nickName": "小旋風",
    "name": "柴進"
  },
  {
    "star": "天富星",
    "nickName": "撲天",
    "name": "李應"
  },
  {
    "star": "天滿星",
    "nickName": "美髯公",
    "name": "朱仝"
  },
  {
    "star": "天孤星",
    "nickName": "花和尚",
    "name": "魯智深"
  },
  {
    "star": "天傷星",
    "nickName": "行者",
    "name": "武松"
  },
  {
    "star": "天立星",
    "nickName": "雙搶將",
    "name": "董平"
  },
  {
    "star": "天捷星",
    "nickName": "沒羽箭",
    "name": "張清"
  },
  {
    "star": "天暗星",
    "nickName": "青面獸",
    "name": "揚志"
  },
  {
    "star": "天佑星",
    "nickName": "金搶手",
    "name": "徐寧"
  },
  {
    "star": "天空星",
    "nickName": "急先鋒",
    "name": "索超"
  },
  {
    "star": "天速星",
    "nickName": "神行太保",
    "name": "戴宗"
  },
  {
    "star": "天異星",
    "nickName": "赤發鬼",
    "name": "劉唐"
  },
  {
    "star": "天殺星",
    "nickName": "黑旋風",
    "name": "李逵"
  },
  {
    "star": "天微星",
    "nickName": "九紋龍",
    "name": "史進"
  },
  {
    "star": "天究星",
    "nickName": "沒遮攔",
    "name": "穆弘"
  },
  {
    "star": "天退星",
    "nickName": "插翅虎",
    "name": "雷橫"
  },
  {
    "star": "天壽星",
    "nickName": "混江龍",
    "name": "李俊"
  },
  {
    "star": "天劍星",
    "nickName": "立地太歲",
    "name": "阮小二"
  },
  {
    "star": "天平星",
    "nickName": "船火兒",
    "name": "張橫"
  },
  {
    "star": "天罪星",
    "nickName": "短命二郎",
    "name": "阮小五"
  },
  {
    "star": "天損星",
    "nickName": "浪裡白條",
    "name": "張順"
  },
  {
    "star": "天敗星",
    "nickName": "活閻羅",
    "name": "阮小七"
  },
  {
    "star": "天牢星",
    "nickName": "病關索",
    "name": "揚雄"
  },
  {
    "star": "天慧星",
    "nickName": "拼命三郎",
    "name": "石秀"
  },
  {
    "star": "天暴星",
    "nickName": "兩頭蛇",
    "name": "解珍"
  },
  {
    "star": "天哭星",
    "nickName": "雙尾蠍",
    "name": "解寶"
  },
  {
    "star": "天巧星",
    "nickName": "浪子",
    "name": "燕青"
  },
  {
    "star": "地魁星",
    "nickName": "神機軍師",
    "name": "朱武"
  },
  {
    "star": "地煞星",
    "nickName": "鎮三山",
    "name": "黃信"
  },
  {
    "star": "地勇星",
    "nickName": "病尉遲",
    "name": "孫立"
  },
  {
    "star": "地傑星",
    "nickName": "醜郡馬",
    "name": "宣贊"
  },
  {
    "star": "地雄星",
    "nickName": "井木犴",
    "name": "赦思文"
  },
  {
    "star": "地威星",
    "nickName": "百勝將軍",
    "name": "韓滔"
  },
  {
    "star": "地英星",
    "nickName": "天目將軍",
    "name": "彭璣"
  },
  {
    "star": "地奇星",
    "nickName": "聖水將軍",
    "name": "單廷"
  },
  {
    "star": "地猛星",
    "nickName": "神火將軍",
    "name": "魏定國"
  },
  {
    "star": "地文星",
    "nickName": "聖手書生",
    "name": "蕭讓"
  },
  {
    "star": "地正星",
    "nickName": "鐵面孔目",
    "name": "裴宣"
  },
  {
    "star": "地闢星",
    "nickName": "摩雲金翅",
    "name": "歐鵬"
  },
  {
    "star": "地闔星",
    "nickName": "火眼狻猊",
    "name": "鄧飛"
  },
  {
    "star": "地強星",
    "nickName": "錦毛虎",
    "name": "燕順"
  },
  {
    "star": "地暗星",
    "nickName": "錦豹子",
    "name": "揚林"
  },
  {
    "star": "地軸星",
    "nickName": "轟天雷",
    "name": "凌振"
  },
  {
    "star": "地會星",
    "nickName": "神運算元",
    "name": "蔣敬"
  },
  {
    "star": "地佐星",
    "nickName": "小溫候",
    "name": "呂方"
  },
  {
    "star": "地佑星",
    "nickName": "賽仁貴",
    "name": "郭盛"
  },
  {
    "star": "地靈星",
    "nickName": "神醫",
    "name": "安道全"
  },
  {
    "star": "地獸星",
    "nickName": "紫髯伯",
    "name": "皇浦端"
  },
  {
    "star": "地微星",
    "nickName": "矮腳虎",
    "name": "王英"
  },
  {
    "star": "地慧星",
    "nickName": "一丈青",
    "name": "扈三娘"
  },
  {
    "star": "地暴星",
    "nickName": "喪門神",
    "name": "鮑旭"
  },
  {
    "star": "地默星",
    "nickName": "混世魔王",
    "name": "樊瑞"
  },
  {
    "star": "地猖星",
    "nickName": "毛頭星",
    "name": "孔明"
  },
  {
    "star": "地狂星",
    "nickName": "獨火星",
    "name": "孔亮"
  },
  {
    "star": "地飛星",
    "nickName": "八臂哪吒",
    "name": "項充"
  },
  {
    "star": "地走星",
    "nickName": "飛天大聖",
    "name": "李袞"
  },
  {
    "star": "地巧星",
    "nickName": "玉臂匠",
    "name": "金大堅"
  },
  {
    "star": "地明星",
    "nickName": "鐵笛仙",
    "name": "馬麟"
  },
  {
    "star": "地進星",
    "nickName": "出洞蛟",
    "name": "童威"
  },
  {
    "star": "地退星",
    "nickName": "翻江蜃",
    "name": "童猛"
  },
  {
    "star": "地滿星",
    "nickName": "玉笛",
    "name": "孟康"
  },
  {
    "star": "地遂星",
    "nickName": "通臂猿",
    "name": "候建"
  },
  {
    "star": "地周星",
    "nickName": "跳澗虎",
    "name": "陳達"
  },
  {
    "star": "地隱星",
    "nickName": "白花蛇",
    "name": "揚春"
  },
  {
    "star": "地異星",
    "nickName": "白麵郎君",
    "name": "鄭天壽"
  },
  {
    "star": "地理星",
    "nickName": "九尾龜",
    "name": "陶宗旺"
  },
  {
    "star": "地俊星",
    "nickName": "鐵扇子",
    "name": "宋清"
  },
  {
    "star": "地樂星",
    "nickName": "鐵叫子",
    "name": "樂和"
  },
  {
    "star": "地捷星",
    "nickName": "花項虎",
    "name": "龔旺"
  },
  {
    "star": "地速星",
    "nickName": "中箭虎",
    "name": "丁得孫"
  },
  {
    "star": "地鎮星",
    "nickName": "沒遮攔",
    "name": "穆春"
  },
  {
    "star": "地嵇星",
    "nickName": "刀鬼",
    "name": "曹正"
  },
  {
    "star": "地魔星",
    "nickName": "雲裡金剛",
    "name": "宋萬"
  },
  {
    "star": "地妖星",
    "nickName": "摸著天",
    "name": "杜遷"
  },
  {
    "star": "地幽星",
    "nickName": "病大蟲",
    "name": "薛永"
  },
  {
    "star": "地伏星",
    "nickName": "金眼彪",
    "name": "施恩"
  },
  {
    "star": "地僻星",
    "nickName": "打虎將",
    "name": "李忠"
  },
  {
    "star": "地空星",
    "nickName": "小霸王",
    "name": "周通"
  },
  {
    "star": "地孤星",
    "nickName": "金錢豹子",
    "name": "湯隆"
  },
  {
    "star": "地全星",
    "nickName": "鬼臉兒",
    "name": "杜興"
  },
  {
    "star": "地短星",
    "nickName": "出林龍",
    "name": "鄒淵"
  },
  {
    "star": "地角星",
    "nickName": "獨角龍",
    "name": "鄒潤"
  },
  {
    "star": "地囚星",
    "nickName": "旱地忽律",
    "name": "朱貴"
  },
  {
    "star": "地藏星",
    "nickName": "笑面虎",
    "name": "朱富"
  },
  {
    "star": "地平星",
    "nickName": "鐵臂膊",
    "name": "蔡福"
  },
  {
    "star": "地損星",
    "nickName": "一枝花",
    "name": "蔡慶"
  },
  {
    "star": "地奴星",
    "nickName": "催命判官",
    "name": "李立"
  },
  {
    "star": "地察星",
    "nickName": "青眼虎",
    "name": "李雲"
  },
  {
    "star": "地惡星",
    "nickName": "沒面目",
    "name": "焦挺"
  },
  {
    "star": "地醜星",
    "nickName": "石將軍",
    "name": "石勇"
  },
  {
    "star": "地數星",
    "nickName": "小尉遲",
    "name": "孫新"
  },
  {
    "star": "地陰星",
    "nickName": "母大蟲",
    "name": "顧大嫂"
  },
  {
    "star": "地刑星",
    "nickName": "菜園子",
    "name": "張青"
  },
  {
    "star": "地壯星",
    "nickName": "母夜叉",
    "name": "孫二孃"
  },
  {
    "star": "地劣星",
    "nickName": "活閻婆",
    "name": "王定六"
  }
]
複製程式碼

2.提取書名:(千軍萬馬之中,直取上將首級)

原檔案.png

這個比較簡單,但挺經典的,直接上程式碼:
使用了Pattern+Matcher,對匹配字串進行組命名獲取,組命名方法:?<xxxxx>,獲取方式:matcher.group("xxxxx")

 public void book() {
     Set<String> books = new HashSet<>();
     File file = new File("C:\\Users\\Administrator\\Desktop\\100名著.txt");
     String str = readFile(file);
     Pattern pattern = Pattern.compile("《(?<result>.*?)》");//?<result>是取了一個組名
     Matcher matcher = pattern.matcher(str);
     while (matcher.find()) {
         String book = matcher.group("result");
         books.add(book);
     }
     StringBuilder sb = new StringBuilder("public static String[] " + "BOOKS" + " = new String[]{");
     books.forEach(s -> {
         sb.append("\"《" + s + "》\",");
     });
     sb.append("};");
     System.out.println(sb.toString());
 }
複製程式碼

提取書名.png

很簡單就從複雜的文章中獲取了書名,而且排除了重複的,是不是四兩撥千斤
此字串已收錄:toly_res開源庫


3.貼吧中郵箱的抓取

我用Python抓了一些網頁然後存在了檔案中,本文不注意如何獲取字串,核心在如何獲取有用資料

網頁.png

我們的目標:從6000多行字串中過濾出郵箱

過濾出郵箱.png


3.1:郵箱格式的分析:

正則匹配式(我習慣為組取名字,這樣容易看,不然很容易暈,以後也容易看):
(?<result>(?<first>\w)(?<username>[\w\.]{0,27})@(?<yuming>[\w]+\.(com|cn|com\.cn|net\.cn|edu|gov|org)))

 /**
  * 郵箱驗證
  * 1981462002@qq.com
  * toly.1994_king@123.com
  * ggl0228@163.com
  * wangshizhihao@foxmail.com
  * tchzw@126.com
  * 954007646@aw.com
  * 
  * 使用者名稱:字母、數字、下劃線、點
  * 使用者名稱首字元:字母
  * 使用者:長度小於28
  *
  * 域名:.com .cn .com.cn .net.cn .edu .gov .org
  */
複製程式碼

郵箱分析.png

(?<result>(?<first>\w)(?<username>[\w\.]{0,27})@(?<yuming>[\w]+\.(com|cn|com\.cn|net\.cn|edu|gov|org)))

result組是我們需要的總匹配結果
first組是首字母的格式
username組是除首字母外的使用者名稱格式
yuming組是匹配域名
複製程式碼

3.2:程式碼實現
@Test
public void email() {
    //檔案路徑
    File file = new File("C:\\Users\\Administrator\\Desktop\\郵箱.txt");
    String readFile = readFile(file);
    judgeEmail(readFile);
}
複製程式碼
private void judgeEmail(String target) {

    String regex = "(?<result>(?<first>\\w)(?<username>[\\w\\.]{0,27})@(?<yuming>[\\w]+\\.(com|cn|com\\.cn|net\\.cn|edu|gov|org)))";

    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(target);
    while (matcher.find()) {
        System.out.println(matcher.group("result"));
    }
}
複製程式碼

3.2:連線成靜態字串陣列
private void judgeEmail(String target) {
    String regex = "(?<result>(?<first>\\w)(?<username>[\\w\\.]{0,27})@(?<yuming>[\\w]+\\.(com|cn|com\\.cn|net\\.cn|edu|gov|org)))";
    Pattern pattern = Pattern.compile(regex);//?<result>是取了一個組名
    Matcher matcher = pattern.matcher(target);
    StringBuilder sb = new StringBuilder("public static String[] " + "EMAIL" + " = new String[]{");
    while (matcher.find()) {
        sb.append("\"" + matcher.group("result") + "\",");
    }
    sb.append("};");
    System.out.println(sb.toString());
}
複製程式碼

最終結果.png

好了,控制檯裡拷過去就能用了,打完收工。
此字串已收錄:toly_res開源庫


4.從豆瓣電影的html獲取資料

注:喜歡Python爬蟲的童鞋不要噴,收起你的唾沫,這裡主要演示正則的分析與使用

4.1:開啟豆瓣電影,隨便找一頁,將原始碼拷貝出來(當然你也可以通過程式碼獲取網頁,這無關緊要)

拷貝出來嚇一跳,竟然4000多行,嚇得我手一抖,沒關係分析分析,切切就少了

html.png


4.2:主要的條目如下

用上面的套路,把中間的東西擠出來,一共獲得104組資料

條目1.png

@Test
public void movie() {

    Set<String> movies = new HashSet<>();
    File file = new File("C:\\Users\\Administrator\\Desktop\\豆瓣.txt");
    String str = readFile(file);

    Pattern pattern = Pattern.compile("class=\"item\" target=\"_blank\"(?<result>(.|\\s)*?)</a>");//?<result>是取了一個組名
    Matcher matcher = pattern.matcher(str);
    while (matcher.find()) {
        String result = matcher.group("result");
        System.out.println(result);
        movies.add(result);
    }
}
複製程式碼

效果1.png


4.3:只要將條目再加工,便可以獲取資訊了

方法詳見下:

效果2.png

4.4:建立實體類,承接資料
public class Movie {
    private String name;
    private String imgUrl;
    private String star;
    //get---set---toString略...
}
複製程式碼
@Test
public void movie() {
    ArrayList<Movie> movies = new ArrayList<>();
    File file = new File("C:\\Users\\Administrator\\Desktop\\豆瓣.txt");
    String str = readFile(file);
    Pattern pattern = Pattern.compile("class=\"item\" target=\"_blank\"(?<result>(.|\\s)*?)</a>
    Matcher matcher = pattern.matcher(str);
    while (matcher.find()) {
        Movie movie = new Movie();
        String result = matcher.group("result");
        //獲取名字
        Pattern nameP = Pattern.compile("alt=\"(?<name>(.|\\s)*?)\"");//?<result>是取
        Matcher nameM = nameP.matcher(result);
        while (nameM.find()) {
            String name = nameM.group("name");
            if (!name.contains("<%=")) {
                movie.setName(name);
            }
        }
        //獲取圖片
        Pattern imgurlP = Pattern.compile("<img src=\"(?<imgurl>(.|\\s)*?)\"");
        Matcher imgurlM = imgurlP.matcher(result);
        while (imgurlM.find()) {
            String imgurl = imgurlM.group("imgurl");
            if (imgurl.contains("http") && !imgurl.contains("ic_new.png")) {
                movie.setImgUrl(imgurl);
            }
        }
        //獲取評分
        Pattern starP = Pattern.compile("<strong>(?<star>(.|\\s)*?)</strong>");
        Matcher starM = starP.matcher(result);
        while (starM.find()) {
            String star = starM.group("star");
            if (!star.contains("<%=")) {
                movie.setStar(star);
            }
        }
        movies.add(movie);
    }
    System.out.println(movies.size());//104
}
複製程式碼
4.5:轉化成Json字串備用
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setPrettyPrinting();//美化輸出的json格式化
String json = gsonBuilder.create().toJson(movies);
System.out.println(json);
複製程式碼
[
  {
    "name": "新女性",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2246439495.jpg",
    "star": "8.3"
  },
  {
    "name": "血腥星期天",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p787880217.jpg",
    "star": "8.1"
  },
  {
    "name": "哆啦A夢:大雄的宇宙漂流記",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520702618.jpg",
    "star": "8.1"
  },
  {
    "name": "狐妖小紅娘劇場版:下沙",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2295069298.jpg",
    "star": "8.3"
  },
  {
    "name": "自然之子",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1306331510.jpg",
    "star": "8.3"
  },
  {
    "name": "與安德烈晚餐",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1893376830.jpg",
    "star": "8.2"
  },
  {
    "name": "貓兒歷險記",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1605686921.jpg",
    "star": "8.3"
  },
  {
    "name": "哆啦A夢:大雄和發條都市",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520702327.jpg",
    "star": "8.0"
  },
  {
    "name": "哆啦A夢:大雄的宇宙小戰爭",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520699109.jpg",
    "star": "8.2"
  },
  {
    "name": "大雄的懷念奶奶",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2369337420.jpg",
    "star": "9.5"
  },
  {
    "name": "利茲與青鳥",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2515806508.jpg",
    "star": "8.9"
  },
  {
    "name": "狼屋",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2534473847.jpg",
    "star": "8.0"
  },
  {
    "name": "啊!設計",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2509012048.jpg",
    "star": "9.4"
  },
  {
    "name": "少年泰坦出擊電影版",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2513656628.jpg",
    "star": "8.0"
  },
  {
    "name": "芬妮的旅程",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2358296290.jpg",
    "star": "8.4"
  },
  {
    "name": "大紅燈籠高高掛",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2461788317.jpg",
    "star": "8.8"
  },
  {
    "name": "機動戰士高達THE ORIGIN VI 赤色彗星誕生",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2518242401.jpg",
    "star": "8.7"
  },
  {
    "name": "五月的四天",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p1918431707.jpg",
    "star": "8.6"
  },
  {
    "name": "血色清晨",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p1263506579.jpg",
    "star": "8.0"
  },
  {
    "name": "代號基亞斯:反叛的魯路修1之興道",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2499190654.jpg",
    "star": "8.1"
  },
  {
    "name": "妄想學生會 劇場版",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2503166245.jpg",
    "star": "8.1"
  },
  {
    "name": "笑傲江湖",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2224051619.jpg",
    "star": "8.0"
  },
  {
    "name": "遙望南方的童年",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2516014437.jpg",
    "star": "9.2"
  },
  {
    "name": "機動戰士高達THE ORIGIN V 激戰 魯姆戰役篇",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2499505254.jpg",
    "star": "8.7"
  },
  {
    "name": "山丘之王",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2174134502.jpg",
    "star": "8.1"
  },
  {
    "name": "再世人狗緣",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538276076.jpg",
    "star": "8.2"
  },
  {
    "name": "羅密歐與朱麗葉",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2224933614.jpg",
    "star": "9.4"
  },
  {
    "name": "狐妖小紅娘劇場版:千顏",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2496051870.jpg",
    "star": "8.7"
  },
  {
    "name": "理查三世",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2407018702.jpg",
    "star": "8.5"
  },
  {
    "name": "亞人2:衝突",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2327065799.jpg",
    "star": "8.3"
  },
  {
    "name": "霹靂奇幻 生死一劍",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2518143759.jpg",
    "star": "8.0"
  },
  {
    "name": "克羅埃西亞憲法",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2493755634.jpg",
    "star": "8.2"
  },
  {
    "name": "葛飾北齋:為畫痴狂",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2479070167.jpg",
    "star": "8.1"
  },
  {
    "name": "我這樣過了一生",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2233892203.jpg",
    "star": "8.2"
  },
  {
    "name": "警察與小偷",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2174353218.jpg",
    "star": "8.7"
  },
  {
    "name": "寂靜人生",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2204300672.jpg",
    "star": "8.4"
  },
  {
    "name": "月光詩篇",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2158251717.jpg",
    "star": "8.0"
  },
  {
    "name": "煉獄",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2509224206.jpg",
    "star": "8.5"
  },
  {
    "name": "羅馬11時",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2230837721.jpg",
    "star": "9.1"
  },
  {
    "name": "開戰",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540477486.jpg",
    "star": "8.1"
  },
  {
    "name": "福祿雙霸天",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1690617156.jpg",
    "star": "8.4"
  },
  {
    "name": "銀河鐵道之夜",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p740452252.jpg",
    "star": "8.5"
  },
  {
    "name": "伊麗莎白",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2264336223.jpg",
    "star": "9.6"
  },
  {
    "name": "飛行員的妻子",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2458238800.jpg",
    "star": "8.1"
  },
  {
    "name": "完美對壘",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1284297564.jpg",
    "star": "8.3"
  },
  {
    "name": "紅柿子",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538697684.jpg",
    "star": "8.9"
  },
  {
    "name": "滿城風雨",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2171856537.jpg",
    "star": "8.4"
  },
  {
    "name": "豆滿江",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p862943814.jpg",
    "star": "8.1"
  },
  {
    "name": "溫柔的憐憫",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2176187973.jpg",
    "star": "8.2"
  },
  {
    "name": "影子大地",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p978240555.jpg",
    "star": "8.6"
  },
  {
    "name": "新女性",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2246439495.jpg",
    "star": "8.3"
  },
  {
    "name": "血腥星期天",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p787880217.jpg",
    "star": "8.1"
  },
  {
    "name": "哆啦A夢:大雄的宇宙漂流記",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520702618.jpg",
    "star": "8.1"
  },
  {
    "name": "狐妖小紅娘劇場版:下沙",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2295069298.jpg",
    "star": "8.3"
  },
  {
    "name": "自然之子",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1306331510.jpg",
    "star": "8.3"
  },
  {
    "name": "與安德烈晚餐",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1893376830.jpg",
    "star": "8.2"
  },
  {
    "name": "貓兒歷險記",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p1605686921.jpg",
    "star": "8.3"
  },
  {
    "name": "哆啦A夢:大雄和發條都市",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520702327.jpg",
    "star": "8.0"
  },
  {
    "name": "哆啦A夢:大雄的宇宙小戰爭",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2520699109.jpg",
    "star": "8.2"
  },
  {
    "name": "大雄的懷念奶奶",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2369337420.jpg",
    "star": "9.5"
  },
  {
    "name": "利茲與青鳥",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2515806508.jpg",
    "star": "8.9"
  },
  {
    "name": "狼屋",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2534473847.jpg",
    "star": "8.0"
  },
  {
    "name": "啊!設計",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2509012048.jpg",
    "star": "9.4"
  },
  {
    "name": "少年泰坦出擊電影版",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2513656628.jpg",
    "star": "8.0"
  },
  {
    "name": "芬妮的旅程",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2358296290.jpg",
    "star": "8.4"
  },
  {
    "name": "大紅燈籠高高掛",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2461788317.jpg",
    "star": "8.8"
  },
  {
    "name": "機動戰士高達THE ORIGIN VI 赤色彗星誕生",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2518242401.jpg",
    "star": "8.7"
  },
  {
    "name": "五月的四天",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p1918431707.jpg",
    "star": "8.6"
  },
  {
    "name": "血色清晨",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p1263506579.jpg",
    "star": "8.0"
  },
  {
    "name": "代號基亞斯:反叛的魯路修1之興道",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2499190654.jpg",
    "star": "8.1"
  },
  {},
  {
    "name": "愛犬情深 第一季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2538454688.jpg",
    "star": "9.1"
  },
  {
    "name": "小謝爾頓 第二季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2535092199.jpg",
    "star": "9.4"
  },
  {
    "name": "柯明斯基理論",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2536895917.jpg",
    "star": "8.9"
  },
  {
    "name": "我們由奇蹟構成",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2536589132.jpg",
    "star": "8.7"
  },
  {
    "name": "我就是演員",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2533842667.jpg",
    "star": "7.1"
  },
  {
    "name": "威爾森夫人",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540988694.jpg",
    "star": "8.3"
  },
  {
    "name": "死的讚美",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2539096723.jpg",
    "star": "8.4"
  },
  {
    "name": "貼身保鏢",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2532513937.jpg",
    "star": "8.6"
  },
  {
    "name": "我的老闆每天死一次",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538378560.jpg",
    "star": "8.3"
  },
  {
    "name": "女鼓手",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2536446377.jpg",
    "star": "8.2"
  },
  {
    "name": "風味人間",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2541649132.jpg",
    "star": "9.3"
  },
  {
    "name": "奇葩說 第五季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534020405.jpg",
    "star": "7.1"
  },
  {
    "name": "大帥哥",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2516809760.jpg",
    "star": "7.4"
  },
  {
    "name": "鋒味",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2540670229.jpg",
    "star": "7.6"
  },
  {
    "name": "和陌生人說話 第二季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534613620.jpg",
    "star": "9.5"
  },
  {
    "name": "你和我的傾城時光",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2539658224.jpg",
    "star": "6.1"
  },
  {
    "name": "我是大哥大",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538424795.jpg",
    "star": "9.1"
  },
  {
    "name": "生活大爆炸 第十二季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2535085957.jpg",
    "star": "9.4"
  },
  {
    "name": "我的天才女友 第一季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538458633.jpg",
    "star": "9.4"
  },
  {
    "name": "人不彪悍枉少年",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540868731.jpg",
    "star": "7.9"
  },
  {
    "name": "原來你還在這裡",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2516911622.jpg",
    "star": "7.1"
  },
  {
    "name": "明星大偵探 第四季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538816286.jpg",
    "star": "9.0"
  },
  {
    "name": "奇遇人生",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2533929218.jpg",
    "star": "9.1"
  },
  {
    "name": "我們無法成為野獸",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2537556934.jpg",
    "star": "8.1"
  },
  {
    "name": "一本好書",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2536542410.jpg",
    "star": "9.3"
  },
  {
    "name": "將夜",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538863432.jpg",
    "star": "7.2"
  },
  {
    "name": "毒梟:墨西哥 第一季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2528450871.jpg",
    "star": "9.2"
  },
  {
    "name": "聲入人心",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2537774816.jpg",
    "star": "9.1"
  },
  {
    "name": "王朝",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2537688397.jpg",
    "star": "9.7"
  },
  {
    "name": "美國恐怖故事:啟示錄 第八季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2533307834.jpg",
    "star": "8.0"
  },
  {
    "name": "男朋友",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540938096.jpg",
    "star": "7.2"
  },
  {
    "name": "阿爾罕布拉宮的回憶",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538782562.jpg",
    "star": "8.5"
  },
  {
    "name": "西南聯大",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2539266159.jpg",
    "star": "9.3"
  },
  {
    "name": "如懿傳",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2460165077.jpg",
    "star": "7.4"
  },
  {
    "name": "新西遊記 第五季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2534172628.jpg",
    "star": "9.6"
  },
  {
    "name": "了不起的麥瑟爾夫人 第二季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2540377118.jpg",
    "star": "9.0"
  },
  {
    "name": "鏘鏘行天下",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2534078057.jpg",
    "star": "9.2"
  },
  {
    "name": "大戀愛:與將我忘記的你",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2535742933.jpg",
    "star": "8.7"
  },
  {
    "name": "上新了·故宮",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2537957246.jpg",
    "star": "8.2"
  },
  {
    "name": "生活對我下手了",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540394945.jpg",
    "star": "7.9"
  },
  {
    "name": "請回答1988",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2272563445.jpg",
    "star": "9.7"
  },
  {
    "name": "中學聖日記",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2536470150.jpg",
    "star": "8.0"
  },
  {
    "name": "吐槽大會 第三季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2538347989.jpg",
    "star": "6.4"
  },
  {
    "name": "非自然死亡",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2510604929.jpg",
    "star": "9.3"
  },
  {
    "name": "內在美",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534573970.jpg",
    "star": "8.0"
  },
  {
    "name": "我們的四十年",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538815501.jpg",
    "star": "7.4"
  },
  {
    "name": "幸福一家人",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2531292580.jpg",
    "star": "6.3"
  },
  {
    "name": "鬼入侵",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534588882.jpg",
    "star": "8.7"
  },
  {
    "name": "新西遊記 第六季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2539335911.jpg",
    "star": "9.7"
  },
  {
    "name": "我們這一天 第三季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2533297798.jpg",
    "star": "9.6"
  },
  {
    "name": "愛犬情深 第一季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2538454688.jpg",
    "star": "9.1"
  },
  {
    "name": "小謝爾頓 第二季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2535092199.jpg",
    "star": "9.4"
  },
  {
    "name": "柯明斯基理論",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2536895917.jpg",
    "star": "8.9"
  },
  {
    "name": "我們由奇蹟構成",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2536589132.jpg",
    "star": "8.7"
  },
  {
    "name": "我就是演員",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2533842667.jpg",
    "star": "7.1"
  },
  {
    "name": "威爾森夫人",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540988694.jpg",
    "star": "8.3"
  },
  {
    "name": "死的讚美",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2539096723.jpg",
    "star": "8.4"
  },
  {
    "name": "貼身保鏢",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2532513937.jpg",
    "star": "8.6"
  },
  {
    "name": "我的老闆每天死一次",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538378560.jpg",
    "star": "8.3"
  },
  {
    "name": "女鼓手",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2536446377.jpg",
    "star": "8.2"
  },
  {
    "name": "風味人間",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2541649132.jpg",
    "star": "9.3"
  },
  {
    "name": "奇葩說 第五季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534020405.jpg",
    "star": "7.1"
  },
  {
    "name": "大帥哥",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2516809760.jpg",
    "star": "7.4"
  },
  {
    "name": "鋒味",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2540670229.jpg",
    "star": "7.6"
  },
  {
    "name": "和陌生人說話 第二季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2534613620.jpg",
    "star": "9.5"
  },
  {
    "name": "你和我的傾城時光",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2539658224.jpg",
    "star": "6.1"
  },
  {
    "name": "我是大哥大",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538424795.jpg",
    "star": "9.1"
  },
  {
    "name": "生活大爆炸 第十二季",
    "imgUrl": "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2535085957.jpg",
    "star": "9.4"
  },
  {
    "name": "我的天才女友 第一季",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2538458633.jpg",
    "star": "9.4"
  },
  {
    "name": "人不彪悍枉少年",
    "imgUrl": "https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2540868731.jpg",
    "star": "7.9"
  },
  {}
]
複製程式碼

此字串已收錄:toly_res開源庫


後記:捷文規範

1.本文成長記錄及勘誤表
專案原始碼 日期 備註
V0.1--github 2018-12-6 帶你玩正則1--資料遍地是,看你取不取
2.更多關於我
筆名 QQ 微信 愛好
張風捷特烈 1981462002 zdl1994328 語言
我的github 我的簡書 我的掘金 個人網站
3.宣告

1----本文由張風捷特烈原創,轉載請註明
2----歡迎廣大程式設計愛好者共同交流
3----個人能力有限,如有不正之處歡迎大家批評指證,必定虛心改正
4----看到這裡,我在此感謝你的喜歡與支援


icon_wx_200.png

相關文章