简体   繁体   English

无法解析正则表达式

[英]unable to parse regular expression

I've some data and I want to extract some details from it. 我有一些数据,我想从中提取一些细节。

<div id="ctl00_hpVendorManager">
<h5 class="panelTitle"><span class="title ">Vendor Manager(s)</span></h5>
Resource Manager: CHS MSP HOUSE<br>
Resource Administrator:     
</div>

I want to extract data between </h5> and </div> . 我想提取</h5></div>之间的数据。

Here is the regular expression that I've tried. 这是我尝试过的正则表达式。

>Vendor Manager\(s\).*?<\/h5>(.*?)<\/

but it doesn't seems working. 但它似乎不起作用。

any clue where I'm doing wrong. 任何我做错地方的线索。

First of all you shouldn't use regular expression for such tasks. 首先,您不应该对此类任务使用正则表达式。 Parse the HTML and use something like XPath to extract a portion of it. 解析HTML并使用XPath之类的东西提取其中的一部分。

In case you still want to do it, try a pattern like this: 如果您仍然想要这样做,请尝试以下模式:

<\\/h5>(?s)(.*)<\\/div>

try this: 尝试这个:

<\\/h5>(.|\\n)*?<\\/div>

demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM