2024-09-28 19:26:59 发布
网友
如何匹配XML文件中的这些特定行:
“<;Foobar>;示例创建于2014年9月30日上午11:00:010<;/Foobar>;AZ9999这是一个测试-请帮助备份完整”
到目前为止,我匹配所有字符串
#Regex for matching specific line found = re.match(r"^(?<=FooBar)+(\d+/\d+/\d+).$", text)
我能够读取文件只是无法从文件中提取这些特定的字符串。你知道吗
因为您还没有指定需要查找的内容,所以我无法提供经过测试的代码段。请查看各种帮助页和regexp教程。我可以推荐
http://flockhart.virtualave.net/RBIF0100/regexp.html
https://docs.python.org/2/howto/regex.html
我想你可能需要这样的东西:
def isText(text): found = re.match(r"This is a test", text) if found: return True return False
很容易塌下来
return re.match(r"This is a test", text)
因为您还没有指定需要查找的内容,所以我无法提供经过测试的代码段。请查看各种帮助页和regexp教程。我可以推荐
http://flockhart.virtualave.net/RBIF0100/regexp.html
https://docs.python.org/2/howto/regex.html
我想你可能需要这样的东西:
很容易塌下来
相关问题 更多 >
编程相关推荐