首页 > 解决方案 > 正则表达式:也匹配带有未知符号的长字符串

问题描述

我有字符串,超过 1000 多个字符。我的性格就是这样。

<div class='a-body__content has-bbcode'>
    <p class="bb-p"><span class="bb-dropcap bb-dropcap--letter">d Paola all  joined the company after the war, and took oin 1966 to a young designer – the then-unknown, Paris-based Karl Lagerfeld – who took over the aesthetics of the family company and now works with Silvia Venturini Fendi, Anna’s daughter.</p>   
    ---- more 1000+ character 
<div class="footer

我的实际字符串太长然后我展示了一个示例,您可能会注意到,在字符串中,有一些特殊字符。在整个字符串中,像这样的太多特殊字符

我试图<div class='a-body__content抓住<div class="footer

我知道我可以抓住那个特殊字符,.*但是在一个空格之后,它不能匹配空格之后的下一个字符,但是如果我喜欢.*\s.*\s.*,我的模式会变得太长,它只适用于这个字符串,不适用于这种类型的其他字符串,所以我需要一个解决方案来抓取<div class='a-body__contentto<div class="footer和之间的任何字符,以便它适用于这种类型的任何其他字符串。

谁能帮我处理这个案子?

标签: regexweb-crawler

解决方案


我已经解决了这个问题,我这样做了[\s\S]+谢谢


推荐阅读