【问题标题】:i want to match only start tags in regex [duplicate]我只想匹配正则表达式中的开始标签[重复]
【发布时间】:2009-02-23 11:21:20
【问题描述】:

我正在制作一个正则表达式,我只想匹配错误的标签,例如

<p> *some text here, some other tags may be here as well but no ending 'p' tag* </p>

 <P>Affectionately Inscribed </P><P>TO </P><P>HENRY BULLAR, </P><P>(of the western circuit)<P>PREFACE</P>

就像在上面的相同文本中一样,我希望得到&lt;P&gt;(of the western circuit)&lt;P&gt; 的结果,并且不应该捕获任何其他内容。我正在使用它,但它不起作用

<P>[^\(</P>\)]*<P>

请帮忙

【问题讨论】:

标签: c# .net html regex tags


【解决方案1】:

这是一个符合您需要的表达式:

[<]{1}\s*[pP]{1}\s*[>]{1}[()a-zA-Z0-9 ]+[<]{1}\s*[pP]{1}\s*[>]{1}

您可以添加所有需要的字符 [()a-zA-Z0-9 ]。

【讨论】:

    猜你喜欢
    • 2010-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多