这是给定的两个场景
示例 1
the Image Path is https://ictagrisindh.gov.pk/img/inauguration1.jpg the detail goes here
and the url was this and Click here to view the detail goes here
示例 2
https://ictagrisindh.gov.pk/img/inauguration1.jpg the detail goes here
Click here to view screenshot the detail goes here
我的代码如下
import re
str_text = "the Image Path is https://ictagrisindh.gov.pk/img/inauguration1.jpg the detail goes here and the url was this and Click here to view the detail goes here"
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', str_text)
print("Urls: ",":".join(urls))
结果
https://ictagrisindh.gov.pk/img/inauguration1.jpg
我想从起点到终点之间提取文本并从图像路径中的任何地方提取文本
任何帮助将不胜感激并提前感谢