regex - 正则表达式:也匹配带有未知符号的长字符串
问题描述
我有字符串,超过 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__content
to<div class="footer
和之间的任何字符,以便它适用于这种类型的任何其他字符串。
谁能帮我处理这个案子?
解决方案
我已经解决了这个问题,我这样做了[\s\S]+
谢谢
推荐阅读
- java - java.lang.IllegalArgumentException:宽度和高度必须 > 0 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
- swift5 - 覆盖函数:pressBegan 和 pressEnded 不起作用
- java - 如何使用 guice 只注入一个变量?
- python - Python Tensorflow-GPU:“成功打开动态库 cudart64_101.dll”
- python - 返回类变量属性时的python __getattribute__ RecursionError
- oop - 如何克隆工厂创建的对象?
- excel - 在 Power Query 编辑器中比较 2 个不同的行
- c++ - 为什么 std::string::find() 可以处理'\0'?
- arrays - 如何摆脱数组中的幻像行?
- django - 如何解决 django 中的 IntegrityError(FOREIGN KEY 约束失败)?