文章詳情頁
python 正則表達式提取
瀏覽:285日期:2022-08-31 10:45:03
問題描述
41. gnos, gnit, gniz [L, GK]= to know 知李平武. 英語詞根與單詞的說文解字(修訂版) (Kindle 位置 3397-3398). 外語教學與研究出版社. Kindle 版本.42. grad, gress [L]= to step 步李平武. 英語詞根與單詞的說文解字(修訂版) (Kindle 位置 3448-3449). 外語教學與研究出版社. Kindle 版本.
有如上內(nèi)容,怎么樣才可以通過正則表達式僅抓取數(shù)字那一行的內(nèi)容,而忽略掉關(guān)于來源的內(nèi)容呢?
謝謝!
問題解答
回答1:import reregex = r'^d.*'test_str = ('41. gnos, gnit, gniz [L, GK]= to know 知nn' '李平武. 英語詞根與單詞的說文解字(修訂版) (Kindle 位置 3397-3398). 外語教學與研究出版社. Kindle 版本.nn' '42. grad, gress [L]= to step 步nn' '李平武. 英語詞根與單詞的說文解字(修訂版) (Kindle 位置 3448-3449). 外語教學與研究出版社. Kindle 版本.')matches = re.finditer(regex, test_str, re.MULTILINE)for match in matches:print (match.group())
相關(guān)文章:
1. boot2docker無法啟動2. docker-compose中volumes的問題3. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. nignx - docker內(nèi)nginx 80端口被占用5. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.6. javascript - mock.js可以存儲數(shù)據(jù)嗎7. java - SSH框架中寫分頁時service層中不能注入分頁類8. golang - 用IDE看docker源碼時的小問題9. dockerfile - 為什么docker容器啟動不了?
排行榜

熱門標簽
網(wǎng)公網(wǎng)安備