簡體   English   中英

使用正則表達式從文本中提取圖像 url

[英]Extract image urls using regex from a text

我正在嘗試從包含特定單詞的 html 文本中提取所有圖像 url。 我嘗試了以下正則表達式,但它在一些沒有空格的字符串上失敗。

正則表達式

(http\S+logo\S+[.]png|http\S+logo\S+[.]jpg|http\S+logo\S+[.]svg|http\S+logo\S+[.]jpeg)

文本

https://a0.muscache.com/airbnb/static/logos/trips-og-1280x630-9de9c338cc3fd9b5663fb80be0cbe8c2.jpg
https://a0.muscache.com/airbnb/static/logos/trips-og-1280x630-9de9c338cc3fd9b5663fb80be0cbe8c2.png
https://a0.muscache.com/airbnb/static/logos/trips-og-1280x630-9de9c338cc3fd9b5663fb80be0cbe8c2.svg
https://media.glassdoor.com/sqls/575263/uber-squarelogo-1537216184790.png","logo2x":"https://media.glassdoor.com/sqlm/575263/uber-squarelogo-1537216184790.png
"https://media.glassdoor.com/sqls/575263/uber-squarelogo-1537216184790.png","logo2x":"https://media.glassdoor.com/sqlm/575263/uber-squarelogo-1537216184790.png"

任何人都可以說明如何從上面提取圖像網址嗎?

如果您想提取整個 URL,也許,只需:

https:.*?\.(?:png|jpg|svg)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM