我试图使用正则表达式来查看字符串的特定部分并获取介于两者之间的内容,但我无法为此获得正确的正则表达式模式。在
我最大的问题是试图为此建立一个Regex模式。我试着列举了一系列的变化。应该很近。在import re
toFind = ['[]', '[x]']
text = "| Completed?|\n|------|:---------:|\n|Link Created | [] |\n|Research Done | [X] "
# Regex to search between parameters and make result lowercase if there are any uppercase Chars
result = (re.search("(?<=Link Created)(.+?)(?=Research Done)", text).lower())
# Gets rid of whitespace in case they move the []/[x] around
result = result.replace(" ", "")
if any(x in result for x in toFind):
print("Exists")
else:
print("Doesn't Exist")
快乐之路:
我使用string(文本)并使用Regex表达式获取链接创建和研究完成之间的子字符串。在
然后将结果设为小写并去掉空白,以防它们移动[]/[x]s。然后它查看“[]”或“[x]”的字符串(result)并打印。在
实际产量:
目前我一直得到的是没有,因为正则表达式语法是关闭的。。。在