包含和忽略 2 个特殊字符之间的文本

Include and neglect the text between 2 special characters

我有一个与此类似的字符串。

str1=r'<st-button mode="positive" width="small" can-click="{loadConference}" id="meetingPasswordButton">{{i18n "ok"}}</st-button>'

我想包含 <> 之间的所有内容,拒绝 </> 之间的所有内容。

我尝试使用以下代码在这些特殊字符之间包含和拒绝文本。但我无法获得输出。帮我破解这个情况。

代码:

import re
pat = r'(?<=\<).+?(?=\>)' or r'(?<!\</).+?(?!\>)'   

s = r'<st-button mode="positive" width="small" can-click="{loadConference}" id="meetingPasswordButton">{{i18n "ok"}}</st-button>'


print (re.findall(pat, s))

以下正则表达式将 return <> 之间的数据:

print(re.findall('<((?!/).*?)>', s))

输出:

['st-button mode="positive" width="small" can-click="{loadConference}"id="meetingPasswordButton"']
>>> import re
>>> s = r'<st-button mode="positive" width="small" can-click="{loadConference}" id="meetingPasswordButton">{{i18n "ok"}}</st-button>'
>>> print re.findall(r'<([^\/].*?)>', s)
['st-button mode="positive" width="small" can-click="{loadConference}" id="meetingPasswordButton"']