我想捕获所有标签不具有特定标签 [英] i want to capture all tags not having a specific tag

查看:123
本文介绍了我想捕获所有标签不具有特定标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要捕捉指定的所有标签'强',我可以使用<强*<?/ STRONG> 这是工作得很好,但我不希望捕捉这些标签,如果'SPAN'的标签来在这些标签我想是这样< STRONG *(^(SPAN))*<?/ STRONG> 这是示例文本

i want to capture all tags named 'STRONG' i can use <STRONG.*?</STRONG> this is working just fine but i dont want to capture these tags if the 'SPAN' tags come in these tags i want something like <STRONG.*(^(SPAN)).*?</STRONG> this is the sample text

<STRONG> For technical <SPAN id=PageBreak>101</SPAN> please</STRONG>
<SPAN id=PageBreak type="4">56</SPAN><STRONG> visit</STRONG>

我要捕捉的第二强的标签,而不是第一个

i want to capture the second strong tag and not the first one

推荐答案

康拉德是正确的。

但如果你不关心即将到来的厄运,你可以尝试像

But in case you don't care about imminent doom you could try something like

/<STRONG>\w+?<\/STRONG>/

这将忽略STRONG标签,如果他们包围任何不是一个单词字符,如&LT; 的'&LT; SPAN&GT; ,但无疑会失败的任何不寻常的...导致后面约一个注定要失败的尝试点

Which will ignore STRONG tags if they enclose anything that isn't a word character, such as the '<' of '<SPAN>', but will no doubt fail for anything out of the ordinary...leading back to the point about a doomed attempt.

这篇关于我想捕获所有标签不具有特定标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆