Python - 正则判断/获取 markdown 图表、图片链接 元素
正则表达式:
pat_table = '\n\|*.+\|.+\|*\n\|*.+\-+.+\|.+\-+.+\|*\s*.*\n\|*.+\|.+\|*' pat_link = '\!*\[.*?\]\(.*?\)'
调用
text = ''ret = re.findall(pat_link, text, re.MULTILINE)
print(ret, len(ret)) text = '''
a| Syntax | Description |
| --- | ----------- |
| Header | Title |
| Paragraph | Text |b| Syntax | Description | Test Text |
| :--- | :----: | ---: |
| Header | Title | Here's this |
| Paragraph | Text | And more |cSyntax | Description ----------- | ----------- Header | Title Paragraph | Text d
'''ret = re.findall(pat_table, text, re.MULTILINE)
print(ret, len(ret))
2024-10-01(二)