我想要匹配references.But的url一些url有线刹车在它。
示例text =耶鲁气候变化交流项目。纽黑文,CT: xxx大学和乔治·梅森大学;2015年。第1-62页。可从以下网址获得: uploads/2015/04/Global-Warming-CCAM-March-2015.pdf. https://example.xxx.edu/wp-content/
想要匹配:https://example.xxx.edu/wp-content/uploads/2015/04/Global-Warming-CCAM-March-2015.pdf
发布于 2022-11-07 21:04:51
尝试(Regex演示。)
txt = """\
Yale Project on Climate Change Communication. New Haven, CT: xxx University and George
Mason University; 2015. p. 1–62. Available from: https://example.xxx.edu/wp-content/
uploads/2015/04/Global-Warming-CCAM-March-2015.pdf. This is another text just for example"""
import re
pat = re.compile(r"https?://[\S\n]+")
for url in pat.findall(txt):
print(url.replace("\n", "").strip("."))指纹:
https://example.xxx.edu/wp-content/uploads/2015/04/Global-Warming-CCAM-March-2015.pdfhttps://stackoverflow.com/questions/74352789
复制相似问题