正規表現_html要素内の_textContent部分のみにマッチ

 

```python


import re



str_tag


 = '<button>text<img src="image.png">text02</button>'





# 正規表現パターン

pattern = r'>([^<]+)<'



# テキスト部分を抽出

matches = re.findall(pattern, str_tag)



print(matches)  # ['text', 'text02']



コメント