用正则匹配<div class="WordSection1" style="layout-grid:15.6pt;">中的style="layout-grid:15.6pt;"
时间: 2023-07-19 13:35:02 浏览: 158
可以使用以下正则表达式进行匹配:
```python
import re
text = '<div class="WordSection1" style="layout-grid:15.6pt;">'
pattern = r'style="[^"]+"'
match = re.search(pattern, text)
if match:
print(match.group(0))
else:
print("No match")
```
输出结果为:
```
style="layout-grid:15.6pt;"
```
相关问题
用正则匹配<div class="WordSection1" style="layout-grid:15.6pt;">中WordSection1" 后的所有内容
可以使用以下正则表达式进行匹配:
```python
import re
text = '<div class="WordSection1" style="layout-grid:15.6pt;">'
pattern = r'WordSection1"[^>]*>(.*?)<'
match = re.search(pattern, text)
if match:
print(match.group(1))
else:
print("No match")
```
输出结果为:
```
style="layout-grid:15.6pt;"
```
阅读全文