0

示例文本:

'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

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

<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">)

我的正则表达式现在是:

<span.*?>\d+?</span><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">)

现在已经尝试了很多,但我无法让它工作

感谢帮助

4

1 回答 1

1

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

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

通过搜索不是括号的字符,可以更清楚您得到什么。我也有幸在 .* 周围添加了一些无关紧要的令人困惑的空白区域。

于 2012-07-19T09:30:35.553 回答