我有一个文件与大量的网址和普通文本在一起 示例:
'http://oaei.ontologymatching.org/2011/benchmarks/101/onto.rdf#Reference http://oaei.ontologymatching.org/2011/benchmarks/101/onto.rdf#Informal ACADEMIC type http://oaei.ontologymatching.org/2011/benchmarks/101/onto.rdf#school ACADEMIC type'
我想得到:
'Reference Informal ACADEMIC type school ACADEMIC type'
我试过了
substr1 = re.findall(r"#(\w+)", text1)
这是工作的一部分,但我不知道如何提取我想要的这些部分,并将它们与文本中的其他单词结合起来。基本上,我必须去掉URL和“#”符号。有人能帮我吗?你知道吗
将其转过来;删除URL:
演示:
表达式查找以
http://
或https://
开头的任何内容,并删除其后不是哈希或空格的任何内容,包括可选哈希。你知道吗使用
re.findall
:说明:http://regex101.com/r/dV5uR2
相关问题 更多 >
编程相关推荐