首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到正确的正则表达式

找不到正确的正则表达式
EN

Stack Overflow用户
提问于 2012-07-19 17:21:28
回答 1查看 117关注 0票数 0

示例文本:

代码语言:javascript
复制
'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">6. </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">Oktober </span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">1997</span>
<span style="font-family:'Times New Roman'; font-size:6pt; letter-spacing:0.05pt; vertical-align:super">2</span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">),</sp

我的正则表达式应该匹配:

代码语言:javascript
复制
<span style="font-family:'Times New Roman'; font-size:6pt; letter-spacing:0.05pt; vertical-align:super">2</span>
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">)

我的正则表达式现在是:

代码语言:javascript
复制
<span.*?>\d+?</span><span.*?>\)

结果:

代码语言:javascript
复制
<span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">test </span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">6. </span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">Oktober </span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">1997</span>***<span style="font-family:'Times New Roman'; font-size:6pt; letter-spacing:0.05pt; vertical-align:super">2</span><span style="font-family:'Times New Roman'; font-size:9pt; letter-spacing:0.05pt">)

我已经试过很多次了,但是我就是不能工作

感谢你的帮助

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-19 17:30:36

这很难准确阅读,但请尝试:

<span[^>]*>\d+?</span>.*<span[^>]*>

通过搜索不在括号中的字符,您可以更清楚地了解所获得的内容。我也很幸运地添加了.*来处理那些无关紧要的混乱的空白区域。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11557696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档