python中的正则表达式没有给出完整输出

2024-10-02 02:24:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我对python中正则表达式的搜索有问题

文本的某些部分如下所示:

<h3 class="space">Status ogłoszenia</h3>
<div class="under-space gray-row">Aktualne</div>

我想找一个词来代替“Aktualne”,它可以是很多不同的词。 所以我搜索第二行

我已经编写了一些正则表达式代码:

soup = BeautifulSoup(reqs.text, 'lxml')

r = re.search("Status ogłoszenia</h3>\n(.)*</div>", str(soup))

r = str(r)

在输出中,我有:

'<re.Match object; span=(7128, 7199), match=\'Status ogłoszenia</h3>\\n<div class="under-space g>'

所以它不是完全输出。少了一部分

如何将此代码更改为具有完整输出,或者它对我来说是未知的正则表达式行为


Tags: 代码文本divrestatusspaceh3class

热门问题